Commits

PolCPP  committed e2bae98

Added A-B Buttons, with some basic animations/states when pressed. (On desktop they're mapped to control and alt keys).
The GUIManager now also includes an offset value, to move the anchored elements positively and negatively along the X-Axis.

  • Participants
  • Parent commits 17097e5

Comments (0)

Files changed (27)

File Assembly-CSharp-Editor-vs.csproj

 	<DebugType>full</DebugType>
 	<Optimize>false</Optimize>
 	<OutputPath>Temp\bin\Debug\</OutputPath>
-	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_ANDROID;ENABLE_GENERICS;ENABLE_TERRAIN;ENABLE_WEBCAM;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_DUCK_TYPING</DefineConstants>
+	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_STANDALONE_WIN;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE</DefineConstants>
 	<ErrorReport>prompt</ErrorReport>
 	<WarningLevel>4</WarningLevel>
 	<NoWarn>0169</NoWarn>

File Assembly-CSharp-Editor.csproj

 	<DebugType>full</DebugType>
 	<Optimize>false</Optimize>
 	<OutputPath>Temp\bin\Debug\</OutputPath>
-	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_ANDROID;ENABLE_GENERICS;ENABLE_TERRAIN;ENABLE_WEBCAM;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_DUCK_TYPING</DefineConstants>
+	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_STANDALONE_WIN;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE</DefineConstants>
 	<ErrorReport>prompt</ErrorReport>
 	<WarningLevel>4</WarningLevel>
 	<NoWarn>0169</NoWarn>

File Assembly-CSharp-vs.csproj

 	<DebugType>full</DebugType>
 	<Optimize>false</Optimize>
 	<OutputPath>Temp\bin\Debug\</OutputPath>
-	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_ANDROID;ENABLE_GENERICS;ENABLE_TERRAIN;ENABLE_WEBCAM;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW</DefineConstants>
+	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_STANDALONE_WIN;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE</DefineConstants>
 	<ErrorReport>prompt</ErrorReport>
 	<WarningLevel>4</WarningLevel>
 	<NoWarn>0169</NoWarn>

File Assembly-CSharp.csproj

 	<DebugType>full</DebugType>
 	<Optimize>false</Optimize>
 	<OutputPath>Temp\bin\Debug\</OutputPath>
-	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_ANDROID;ENABLE_GENERICS;ENABLE_TERRAIN;ENABLE_WEBCAM;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW</DefineConstants>
+	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_STANDALONE_WIN;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE</DefineConstants>
 	<ErrorReport>prompt</ErrorReport>
 	<WarningLevel>4</WarningLevel>
 	<NoWarn>0169</NoWarn>

File Assembly-CSharp.pidb

Binary file modified.

File Assets/RagePixelAssets/Buttons.asset

Binary file modified.

File Assets/RagePixelAssets/Buttons.png

Old
Old image
New
New image

File Assets/RagePixelAssets/Player.asset

Binary file modified.

File Assets/RagePixelAssets/Player.png

Old
Old image
New
New image

File Assets/Scenes/platform.unity

Binary file modified.

File Assets/Scripts/GUIManager.cs

 {
 	public enum GuiAnchor
 	{
-		bottomLeft=0
+		bottomLeft=0,
+		bottomRight
 	};
+	public int offset = 0;
+	
 	public GuiAnchor anchor = GuiAnchor.bottomLeft;
 		
 	void Awake ()
 		// b) It uses it to relocate to it's 0,0
 		Camera camera = transform.parent.gameObject.camera;
 		switch (anchor) {
-		case GuiAnchor.bottomLeft:	
-			Vector3 zeroPoint = camera.ViewportToWorldPoint (Vector3.zero);
-			zeroPoint.z = gameObject.transform.position.z;
-			gameObject.transform.position = zeroPoint;			
-			break;
+			case GuiAnchor.bottomLeft:	
+				Vector3 zeroPoint = camera.ViewportToWorldPoint (Vector3.zero);
+				zeroPoint.z = gameObject.transform.position.z;
+				zeroPoint.x += offset;
+				gameObject.transform.position = zeroPoint;			
+				break;
+			
+			case GuiAnchor.bottomRight:	
+				Vector3 onePoint = camera.ViewportToWorldPoint (new Vector3(1,0,0));
+				onePoint.z = gameObject.transform.position.z;
+				onePoint.x += offset;
+				gameObject.transform.position = onePoint;
+				break;
 		}
-
 	}
 }

File Assets/Scripts/InputManager.cs

 	private const string PlayerGoName = "Player";
 	private const string LeftButtonGoName = "LeftButton";
 	private const string RightButtonGoName = "RightButton";	
+	private const string AButtonGoName = "AButton";
+	private const string BButtonGoName = "BButton";
 	
 	public enum InputMode
 	{
 	};
 	private int buttonStatus = 0;
 	private int touchStatus = 0;
+	private int abTouchStatus = 0;
 	private PlayerCharacter player;
 	private Button leftButton;
 	private Button rightButton;
+	private Button aButton;
+	private Button bButton;
 	private RaycastHit hit;
 	private Ray ray;
-	private int directionFingerID = -1;  	
+	private int directionFingerID = -1;
+	private int abFingerID = -1;
 
 	void Awake ()
 	{
 		#if UNITY_IPHONE || UNITY_ANDROID
 			GameObject leftButtonGo = GameObject.Find(LeftButtonGoName);
 			GameObject rightButtonGo = GameObject.Find(RightButtonGoName);		
+			GameObject aButtonGo = GameObject.Find(AButtonGoName);		
+			GameObject bButtonGo = GameObject.Find(BButtonGoName);		
 			if (!leftButtonGo)
 				throw new Exception("Cannot find a gameobject named " + LeftButtonGoName );
 			if (!rightButtonGo)
 				throw new Exception("Cannot find a gameobject named " + RightButtonGoName);
+			if (!aButtonGo)
+				throw new Exception("Cannot find a gameobject named " + AButtonGoName);
+			if (!bButtonGo)
+				throw new Exception("Cannot find a gameobject named " + BButtonGoName);
+		
 			leftButton = (Button) leftButtonGo.GetComponent(typeof(Button));
 			rightButton = (Button) rightButtonGo.GetComponent(typeof(Button));		
+			aButton = (Button) aButtonGo.GetComponent(typeof(Button));		
+			bButton = (Button) bButtonGo.GetComponent(typeof(Button));		
 		#endif
 	}
 	
 	void ManageMove ()
 	{
-		// First we'll analyse the Movement axis, we'll get, -1 for left and 1 for right.
+		// We'll analyse all Touch input.
 		buttonStatus = (int)Input.GetAxis ("Horizontal");
-
 		foreach (Touch touch in Input.touches) {
 			if (touch.phase == TouchPhase.Began || touch.phase == TouchPhase.Moved) {
 				ray = Camera.main.ScreenPointToRay (touch.position);
 				if (Physics.Raycast (ray, out hit)) {
 					if (hit.transform.gameObject.name == LeftButtonGoName)  {
 						directionFingerID = touch.fingerId;						
-						touchStatus = -1;						
+						touchStatus = -1;
+						break;
+					}
+					else if (hit.transform.gameObject.name == RightButtonGoName) {
+						directionFingerID = touch.fingerId;						
+						touchStatus = 1;				
+						break;
 					}
 					else if (hit.transform.gameObject.name == RightButtonGoName) {
-						directionFingerID = touch.fingerId;
+						directionFingerID = touch.fingerId;						
 						touchStatus = 1;				
+						break;
+					}
+					else if (hit.transform.gameObject.name == AButtonGoName) {
+						abFingerID = touch.fingerId;						
+						abTouchStatus = 1;				
+						break;
+					}
+					else if (hit.transform.gameObject.name == BButtonGoName) {
+						abFingerID = touch.fingerId;						
+						abTouchStatus = -1;				
+						break;
 					}
 				}
 			} else if (touch.phase == TouchPhase.Ended && touch.fingerId == directionFingerID) {
 				directionFingerID = -1;
 				touchStatus = 0;
+			} else if (touch.phase == TouchPhase.Ended && touch.fingerId == abFingerID) {
+				abFingerID = -1;
+				abTouchStatus = 0;
 			}
 		}
+		
 		if (buttonStatus == 1 || touchStatus == 1) {
 			player.Move (PlayerCharacter.WalkingState.WalkRight);
 			#if UNITY_IPHONE || UNITY_ANDROID
 				leftButton.Press(Button.ButtonStatus.Pressed);
 				rightButton.Press(Button.ButtonStatus.Normal);
 			#endif
-		} else if (buttonStatus == 0 && touchStatus == 0) {
+		} if (buttonStatus == 0 && touchStatus == 0) {
 			player.Move (PlayerCharacter.WalkingState.Standing);	
 			#if UNITY_IPHONE || UNITY_ANDROID
 				leftButton.Press(Button.ButtonStatus.Normal);
 				rightButton.Press(Button.ButtonStatus.Normal);
 			#endif
 
-		}		
+		}	
+
+		// A-B button status
+		buttonStatus = (int)Input.GetAxis ("AButton");
+		if (buttonStatus == 1 || abTouchStatus == 1) {
+			player.Move (PlayerCharacter.WalkingState.Jump);	
+			#if UNITY_IPHONE || UNITY_ANDROID
+				aButton.Press(Button.ButtonStatus.Pressed);
+				bButton.Press(Button.ButtonStatus.Normal);			
+			#endif
+		} else {
+			if (buttonStatus == 0 && abTouchStatus == 0) {
+				#if UNITY_IPHONE || UNITY_ANDROID
+					aButton.Press(Button.ButtonStatus.Normal);			
+					bButton.Press(Button.ButtonStatus.Normal);			
+				#endif
+			}			
+			buttonStatus = (int)Input.GetAxis ("BButton");
+			if (buttonStatus == 1 || abTouchStatus == -1) {
+				player.Move (PlayerCharacter.WalkingState.Casting);	
+				#if UNITY_IPHONE || UNITY_ANDROID
+					aButton.Press(Button.ButtonStatus.Normal);			
+					bButton.Press(Button.ButtonStatus.Pressed);				
+				#endif
+			} 		
+		}
 	}
 }

File Assets/Scripts/PlayerCharacter.cs

 	{
 		Standing=0,
 		WalkRight,
-		WalkLeft
+		WalkLeft,
+		Jump,
+		Casting
 	};
 	public WalkingState state = WalkingState.Standing;
 	public bool flipState = false;
 			state = WalkingState.WalkRight;
 		} else if (direction == WalkingState.WalkLeft) {
 			state = WalkingState.WalkLeft;									
+		} else if (direction == WalkingState.Jump) {
+			state = WalkingState.Jump;		
+		} else if (direction == WalkingState.Casting) {
+			state = WalkingState.Casting;				
 		} else {
-			state = WalkingState.Standing;			
-		}		
+			state = WalkingState.Standing;		
+		}
 	}
 	
 	void Update ()
 	{
-
-		Vector3 moveDirection = new Vector3 ();
-        
+		Vector3 moveDirection = Vector3.zero;
 		switch (state) {
 		case(WalkingState.Standing):
                 //Reset the horizontal flip for clarity
                 //Move direction. X grows right so left is +1.
 			moveDirection = new Vector3 (1f, 0f, 0f);
 			break;
+
+		case (WalkingState.Jump):
+			ragePixel.SetHorizontalFlip (flipState);
+                //PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts.
+			ragePixel.PlayNamedAnimation ("Jump", false);
+			break;
+		
+		case (WalkingState.Casting):
+			ragePixel.SetHorizontalFlip (flipState);
+			//PlayAnimation with forceRestart=false. If the WALK animation is already running, doesn't do anything. Otherwise restarts.
+			ragePixel.PlayNamedAnimation ("Cast", false);
+			break;
+		
 		}
 		//Move the sprite into moveDirection at walkingSpeed pixels/sec
 		transform.Translate (moveDirection * Time.deltaTime * walkingSpeed);

File Library/AssetImportState

-13;0;-1
+4;0;-1

File Library/EditorUserBuildSettings.asset

Binary file modified.

File Library/InspectorExpandedItems.asset

Binary file modified.

File Library/expandedItems

Binary file modified.

File Library/metadata/17/177db863d1cf54b1b9e439f041143507

Binary file modified.

File Library/metadata/33/33e326721a4ce41fd9197cf4e3c68eb9

Binary file modified.

File Library/metadata/44/44278af768a09498f81d2830a0b1d06d

Binary file modified.

File Library/metadata/bf/bfdc361f8eaf94ba3940d9ea57cd1c85

Binary file modified.

File Library/metadata/dd/ddd4045b8f81348f5ba8ba18e13ab1ee

Binary file modified.

File Library/metadata/e8/e8d0b74daf2334bff98b9be8c0b604a1

Binary file modified.

File ProjectSettings/InputManager.asset

Binary file modified.

File twisted-potions-double-trouble-csharp.sln

 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
-																																						GlobalSection(MonoDevelopProperties) = preSolution
+																																									GlobalSection(MonoDevelopProperties) = preSolution
 		StartupItem = Assembly-CSharp.csproj
 		Policies = $0
 		$0.TextStylePolicy = $1

File twisted-potions-double-trouble.sln

 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
-																																					GlobalSection(MonoDevelopProperties) = preSolution
+																																								GlobalSection(MonoDevelopProperties) = preSolution
 		StartupItem = Assembly-CSharp.csproj
 		Policies = $0
 		$0.TextStylePolicy = $1

File twisted-potions-double-trouble.userprefs

   <MonoDevelop.Ide.Workbench ActiveDocument="Assets/Scripts/InputManager.cs">
     <Files>
       <File FileName="Assets/scripts/PlayerCharacter.cs" Line="52" Column="9" />
-      <File FileName="Assets/scripts/InputManager.cs" Line="73" Column="3" />
+      <File FileName="Assets/scripts/InputManager.cs" Line="72" Column="48" />
       <File FileName="Assets/scripts/GUIManager.cs" Line="14" Column="17" />
       <File FileName="Assets/scripts/Button.cs" Line="16" Column="19" />
       <File FileName="Assets/scripts/CameraManager.cs" Line="58" Column="2" />
       <File FileName="Assets/TileMapper/Code/TileMap.cs" Line="1" Column="1" />
       <File FileName="Assets/TileMapper/Code/TileSet.cs" Line="1" Column="1" />
       <File FileName="Assets/TileMapper/Code/Layer.cs" Line="1" Column="1" />
-      <File FileName="Assets/Scripts/InputManager.cs" Line="1" Column="1" />
+      <File FileName="Assets/Scripts/InputManager.cs" Line="31" Column="36" />
     </Files>
   </MonoDevelop.Ide.Workbench>
   <MonoDevelop.Ide.DebuggingService.Breakpoints>