Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented mobile controls #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions Assembly-CSharp-vs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{82046576-C011-7ADA-282F-8E9E2216DFF3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace></RootNamespace>
<AssemblyName>Assembly-CSharp</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<BaseDirectory>Assets</BaseDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_4_6_0;UNITY_4_6;UNITY_ANDROID;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_UNITYEVENTS;ENABLE_NEW_HIERARCHY ;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;INCLUDE_WP8SUPPORT;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_4_6_FEATURES;INCLUDE_WP_BLUE_SUPPORT;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;UNITY_ANDROID_API;ENABLE_2D_PHYSICS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Temp\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.XML" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="UnityEngine">
<HintPath>C:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEditor">
<HintPath>C:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEditor.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\Done\Done_Scripts\Done_BGScroller.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_DestroyByBoundary.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_DestroyByContact.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_DestroyByTime.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_EvasiveManeuver.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_FireButton.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_GameController.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_JoyStick.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_Mover.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_PlayerController.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_RandomRotator.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_WeaponController.cs" />
<Reference Include="UnityEngine.UI">
<HintPath>C:/Program Files (x86)/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/4.6.0/UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
74 changes: 74 additions & 0 deletions Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{82046576-C011-7ADA-282F-8E9E2216DFF3}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace></RootNamespace>
<AssemblyName>Assembly-CSharp</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<BaseDirectory>Assets</BaseDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Temp\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;UNITY_4_6_0;UNITY_4_6;UNITY_ANDROID;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_UNITYEVENTS;ENABLE_NEW_HIERARCHY ;ENABLE_AUDIO_FMOD;ENABLE_MONO;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;INCLUDE_WP8SUPPORT;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_4_6_FEATURES;INCLUDE_WP_BLUE_SUPPORT;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;ENABLE_CACHING;ENABLE_CLOTH;UNITY_ANDROID_API;ENABLE_2D_PHYSICS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Temp\bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0169</NoWarn>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.XML" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="UnityEngine">
<HintPath>C:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEditor">
<HintPath>C:/Program Files (x86)/Unity/Editor/Data/Managed/UnityEditor.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Assets\Done\Done_Scripts\Done_BGScroller.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_DestroyByBoundary.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_DestroyByContact.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_DestroyByTime.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_EvasiveManeuver.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_FireButton.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_GameController.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_JoyStick.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_Mover.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_PlayerController.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_RandomRotator.cs" />
<Compile Include="Assets\Done\Done_Scripts\Done_WeaponController.cs" />
<Reference Include="UnityEngine.UI">
<HintPath>C:/Program Files (x86)/Unity/Editor/Data/UnityExtensions/Unity/GUISystem/4.6.0/UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->

</Project>
Binary file modified Assets/Done/Done_Scenes/Done_Main.unity
Binary file not shown.
27 changes: 27 additions & 0 deletions Assets/Done/Done_Scripts/Done_FireButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class Done_FireButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler {

public Image image;
public bool pressed = false;

public void OnPointerDown(PointerEventData pointerEventData)
{
pressed = true;

Color color = image.color;
color.a = 0.25f;
image.color = color;
}

public void OnPointerUp(PointerEventData pointerEventData)
{
pressed = false;

Color color = image.color;
color.a = 0.75f;
image.color = color;
}
}
8 changes: 8 additions & 0 deletions Assets/Done/Done_Scripts/Done_FireButton.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions Assets/Done/Done_Scripts/Done_GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ void Update ()
{
if (restart)
{
if (Input.GetKeyDown (KeyCode.R))
//Converted this to click instead so that the game could be restarted
//if (Input.GetKeyDown (KeyCode.R))
if(Input.GetButton ("Fire1") || (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began))
{
Application.LoadLevel (Application.loadedLevel);
}
Expand All @@ -57,7 +59,7 @@ IEnumerator SpawnWaves ()

if (gameOver)
{
restartText.text = "Press 'R' for Restart";
restartText.text = "Press anywhere to restart";
restart = true;
break;
}
Expand All @@ -75,9 +77,9 @@ void UpdateScore ()
scoreText.text = "Score: " + score;
}

public void GameOver ()
{
public void GameOver () {
gameOverText.text = "Game Over!";
gameOver = true;
}

}
30 changes: 30 additions & 0 deletions Assets/Done/Done_Scripts/Done_JoyStick.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using UnityEngine;
using UnityEngine.EventSystems;
using System.Collections;

public class Done_JoyStick : MonoBehaviour, IDragHandler, IEndDragHandler {

public RectTransform joystick;

public float sensitivity;

public void OnDrag(PointerEventData pointerEventData)
{
joystick.anchoredPosition += (pointerEventData.delta * sensitivity);

if(Vector2.Distance(Vector2.zero, joystick.anchoredPosition) > 150f)
{
joystick.anchoredPosition = joystick.anchoredPosition.normalized * 150f;
}
}

public void OnEndDrag(PointerEventData pointerEventData)
{
joystick.anchoredPosition = Vector2.zero;
}

public Vector2 GetJoystickValue()
{
return (joystick.anchoredPosition - Vector2.zero) / 150f;
}
}
8 changes: 8 additions & 0 deletions Assets/Done/Done_Scripts/Done_JoyStick.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions Assets/Done/Done_Scripts/Done_PlayerController.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

[System.Serializable]
Expand All @@ -9,6 +10,9 @@ public class Done_Boundary

public class Done_PlayerController : MonoBehaviour
{
public Done_JoyStick joystick;
public Done_FireButton fireButton;

public float speed;
public float tilt;
public Done_Boundary boundary;
Expand All @@ -18,10 +22,10 @@ public class Done_PlayerController : MonoBehaviour
public float fireRate;

private float nextFire;
void Update ()

void Update()
{
if (Input.GetButton("Fire1") && Time.time > nextFire)
if(fireButton.pressed && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
Expand All @@ -31,8 +35,10 @@ void Update ()

void FixedUpdate ()
{
float moveHorizontal = Input.GetAxis ("Horizontal");
float moveVertical = Input.GetAxis ("Vertical");
Vector2 value = joystick.GetJoystickValue ();

float moveHorizontal = value.x;
float moveVertical = value.y;

Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement * speed;
Expand Down
Binary file modified ProjectSettings/EditorBuildSettings.asset
Binary file not shown.
Binary file modified ProjectSettings/GraphicsSettings.asset
Binary file not shown.
Binary file modified ProjectSettings/ProjectSettings.asset
Binary file not shown.
15 changes: 15 additions & 0 deletions unitydemo-SpaceShooter.userprefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<Properties>
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\Done\Done_Scripts\Done_FireButton.cs">
<Files>
<File FileName="Assets\Done\Done_Scripts\Done_GameController.cs" Line="36" Column="47" />
<File FileName="Assets\Done\Done_Scripts\Done_PlayerController.cs" Line="33" Column="4" />
<File FileName="Assets\Done\Done_Scripts\Done_JoyStick.cs" Line="9" Column="26" />
<File FileName="Assets\Done\Done_Scripts\Done_FireButton.cs" Line="25" Column="23" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>