1. PolCPP
  2. Twisted Potions Double Trouble

Commits

PolCPP  committed 261602a

Refactored/Rewritten the Camera, Gui, Controller/Input, Character.

GUI is now parented to the camera so there's no more need to update it's position by frame.
You can now use keyboard to move the character.
There is multitouch support on devices that support it.
It shouldn't show the controller UI on the desktop/web builds.

  • Participants
  • Parent commits f822323
  • Branches master

Comments (0)

Files changed (29)

File Assembly-CSharp-Editor-vs.csproj

View file
 	<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
 	<ProductVersion>10.0.20506</ProductVersion>
 	<SchemaVersion>2.0</SchemaVersion>
-	<ProjectGuid>{360AD0B0-0B7F-9E63-660B-D96E5771AD17}</ProjectGuid>
+	<ProjectGuid>{59F7941D-6875-1925-C4C5-786A44136D76}</ProjectGuid>
 	<OutputType>Library</OutputType>
 	<AppDesignerFolder>Properties</AppDesignerFolder>
 	<RootNamespace></RootNamespace>
 	<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_WEBPLAYER;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE</DefineConstants>
+	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_IOS;UNITY_IPHONE;ENABLE_GENERICS;ENABLE_TERRAIN;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_DUCK_TYPING</DefineConstants>
 	<ErrorReport>prompt</ErrorReport>
 	<WarningLevel>4</WarningLevel>
 	<NoWarn>0169</NoWarn>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="Assembly-CSharp-vs.csproj">
-      <Project>{B210263A-6BC4-671D-064D-23E6D7A3EC8B}</Project>      <Name>Assembly-CSharp-vs</Name>    </ProjectReference>
+      <Project>{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}</Project>      <Name>Assembly-CSharp-vs</Name>    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

File Assembly-CSharp-Editor.csproj

View file
 	<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
 	<ProductVersion>10.0.20506</ProductVersion>
 	<SchemaVersion>2.0</SchemaVersion>
-	<ProjectGuid>{360AD0B0-0B7F-9E63-660B-D96E5771AD17}</ProjectGuid>
+	<ProjectGuid>{59F7941D-6875-1925-C4C5-786A44136D76}</ProjectGuid>
 	<OutputType>Library</OutputType>
 	<AppDesignerFolder>Properties</AppDesignerFolder>
 	<RootNamespace></RootNamespace>
 	<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_WEBPLAYER;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE</DefineConstants>
+	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_IOS;UNITY_IPHONE;ENABLE_GENERICS;ENABLE_TERRAIN;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_DUCK_TYPING</DefineConstants>
 	<ErrorReport>prompt</ErrorReport>
 	<WarningLevel>4</WarningLevel>
 	<NoWarn>0169</NoWarn>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="Assembly-CSharp.csproj">
-      <Project>{B210263A-6BC4-671D-064D-23E6D7A3EC8B}</Project>      <Name>Assembly-CSharp</Name>    </ProjectReference>
+      <Project>{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}</Project>      <Name>Assembly-CSharp</Name>    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 

File Assembly-CSharp-Editor.pidb

Binary file modified.

File Assembly-CSharp-vs.csproj

View file
 	<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
 	<ProductVersion>10.0.20506</ProductVersion>
 	<SchemaVersion>2.0</SchemaVersion>
-	<ProjectGuid>{B210263A-6BC4-671D-064D-23E6D7A3EC8B}</ProjectGuid>
+	<ProjectGuid>{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}</ProjectGuid>
 	<OutputType>Library</OutputType>
 	<AppDesignerFolder>Properties</AppDesignerFolder>
 	<RootNamespace></RootNamespace>
 	<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_WEBPLAYER;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE</DefineConstants>
+	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_IOS;UNITY_IPHONE;ENABLE_GENERICS;ENABLE_TERRAIN;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW</DefineConstants>
 	<ErrorReport>prompt</ErrorReport>
 	<WarningLevel>4</WarningLevel>
 	<NoWarn>0169</NoWarn>
      <Compile Include="Assets\RagePixel\Code\RagePixelSettings.cs" />
      <Compile Include="Assets\RagePixel\Code\RagePixelSprite.cs" />
      <Compile Include="Assets\RagePixel\Code\RagePixelSpriteSheet.cs" />
-     <Compile Include="Assets\scripts\CameraFollow.cs" />
+     <Compile Include="Assets\scripts\CameraController.cs" />
+     <Compile Include="Assets\scripts\GUIController.cs" />
+     <Compile Include="Assets\scripts\InputController.cs" />
      <Compile Include="Assets\scripts\PlayerChar.cs" />
      <Compile Include="Assets\scripts\VirtualPad.cs" />
      <None Include="Assets\RagePixel\readme.txt" />

File Assembly-CSharp.csproj

View file
 	<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
 	<ProductVersion>10.0.20506</ProductVersion>
 	<SchemaVersion>2.0</SchemaVersion>
-	<ProjectGuid>{B210263A-6BC4-671D-064D-23E6D7A3EC8B}</ProjectGuid>
+	<ProjectGuid>{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}</ProjectGuid>
 	<OutputType>Library</OutputType>
 	<AppDesignerFolder>Properties</AppDesignerFolder>
 	<RootNamespace></RootNamespace>
 	<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_WEBPLAYER;ENABLE_GENERICS;ENABLE_DUCK_TYPING;ENABLE_TERRAIN;ENABLE_MOVIES;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW;ENABLE_SUBSTANCE</DefineConstants>
+	<DefineConstants>DEBUG;TRACE;UNITY_3_5_4;UNITY_3_5;UNITY_EDITOR;ENABLE_PROFILER;UNITY_IOS;UNITY_IPHONE;ENABLE_GENERICS;ENABLE_TERRAIN;ENABLE_WEBCAM;ENABLE_MICROPHONE;ENABLE_NETWORK;ENABLE_CLOTH;ENABLE_WWW</DefineConstants>
 	<ErrorReport>prompt</ErrorReport>
 	<WarningLevel>4</WarningLevel>
 	<NoWarn>0169</NoWarn>
      <Compile Include="Assets\RagePixel\Code\RagePixelSettings.cs" />
      <Compile Include="Assets\RagePixel\Code\RagePixelSprite.cs" />
      <Compile Include="Assets\RagePixel\Code\RagePixelSpriteSheet.cs" />
-     <Compile Include="Assets\scripts\CameraFollow.cs" />
+     <Compile Include="Assets\scripts\CameraController.cs" />
+     <Compile Include="Assets\scripts\GUIController.cs" />
+     <Compile Include="Assets\scripts\InputController.cs" />
      <Compile Include="Assets\scripts\PlayerChar.cs" />
      <Compile Include="Assets\scripts\VirtualPad.cs" />
      <None Include="Assets\RagePixel\readme.txt" />

File Assembly-CSharp.pidb

Binary file modified.

File Assets/RagePixelAssets/Buttons.mat

Binary file modified.

File Assets/RagePixelAssets/Tile.mat

Binary file added.

File Assets/Scenes/platform.unity

Binary file modified.

File Assets/scripts/CameraController.cs

View file
+using UnityEngine;
+using System.Collections;
+using System;
+
+public class CameraController: MonoBehaviour
+{
+	// The player character to follow.
+	private const string PlayerGoName = "Player";
+	
+	public enum CameraFormat {followTarget=0};
+	public CameraFormat state = CameraFormat.followTarget;
+		
+	private GameObject player;	
+	
+	// Half and quarter screen are used to measuer 50% screen points
+	// And 25% points, to know when to move the camera on followtarget mode
+	private Vector3 halfScreen = new Vector3(0.5f,0.5f,0);
+	private Vector3 quarterScreen = new Vector3(0.25f,0.25f,0);
+	
+	private Vector3 halfDelta;
+	private Vector3 quarterDelta;
+	
+	// The zeroPoint will be used to know when we got to the earliest
+	// part of the map, the onePoint does the same on the other side.
+	// They show the position on the Right bottom corner and left top
+	// corner
+	private Vector3 zeroPoint;
+	private Vector3 onePoint;
+	
+	// The point where the camera will stop following the character 
+	// (meaning the map is over)
+	private int mapXLength = 1000;
+	private int mapYLength = 1000;	
+	
+	private Vector3 destination;	
+	 
+	// We'll make it the same as the target speed on load
+    private float cameraSpeed = 50f;	
+
+	void Awake () {
+		setPixelResolution();
+		switch (this.state) {
+			case CameraFormat.followTarget:
+				awakeFollowTarget();
+				break;		
+		}
+	}
+	
+	void Update () {
+		switch (this.state) {
+			case CameraFormat.followTarget:
+			updateFollowTarget();
+			break;			
+		}
+	}
+
+	// Changes the screen resolution of the camera
+    public void setPixelResolution()
+    {
+		int pixelSize = 1;		
+		if (Screen.width >= 960 && Screen.height >= 600) {
+			pixelSize = 2;	
+		}
+		Camera camera = gameObject.camera;
+
+		camera.orthographic = true;
+
+		float screenH = Screen.height;
+        camera.orthographicSize = screenH / 2 / pixelSize;
+    }	
+			
+	
+	
+	void awakeFollowTarget() {
+		// We get our target, or throw and exception if it's not set		
+		GameObject playerGo = GameObject.Find(PlayerGoName);
+		if (!playerGo)
+			throw new Exception("Cannot find a gameobject named " + PlayerGoName);
+		this.player = playerGo;		
+		
+		// Makes the camera follow the character åt the same speed of him.
+		PlayerChar pc;
+		if (player) { 
+			pc = (PlayerChar)player.GetComponent(typeof(PlayerChar));
+			this.cameraSpeed = pc.walkingSpeed;
+		}		
+	}
+	
+	void updateFollowTarget() {
+	    if(player) {	        
+			destination = Vector3.zero;
+			// We want to know if our target will go farther than 50% screen and
+			// less than 25%, in both up and down directions. 
+			// So we'll get the delta of our target and the point of half and quarter the screen. 			
+			halfDelta = player.transform.position - camera.ViewportToWorldPoint(halfScreen);						
+			quarterDelta = player.transform.position - camera.ViewportToWorldPoint(quarterScreen);						
+			
+			// Now we check if we need to move. 
+			// Since we're going pixel based the camera will move in 1 unit ranges (nondecimal).
+			if (halfDelta.x > 0)
+				destination.x = 1;
+			if (halfDelta.y > 0)
+				destination.y = 1;	
+			if (quarterDelta.x < 0)
+				destination.x = -1;
+			if (quarterDelta.y < 0)
+				destination.y = -1;	
+			
+			// Now before we update, we check if we're not on the 0 edge. 
+			// TODO: Vertical movement
+			// Plus we only check it if we're moving
+			if (destination != Vector3.zero) {
+				zeroPoint = camera.ViewportToWorldPoint(Vector3.zero);						
+				onePoint = camera.ViewportToWorldPoint(Vector3.one);
+				if (zeroPoint.x <= 0 && destination.x < 0)
+					destination.x = 0;
+				if (onePoint.x >=  mapXLength && destination.x > 0)
+					destination.x = 0;
+			}
+		
+			// Finally we update the camera
+			transform.Translate(destination * Time.deltaTime * this.cameraSpeed);
+		}				
+	}
+	
+}
+

File Assets/scripts/CameraFollow.cs

-using UnityEngine;
-using System.Collections;
-
-public class CameraFollow : MonoBehaviour {
-	
-	// The player character to follow.
-	public Transform target;
-	// Our Gui (which will follow the camera)
-	public Transform gui;
-	
-	private Vector3 halfScreen = new Vector3(0.5f,0.5f,0);
-	private Vector3 quarterScreen = new Vector3(0.25f,0.25f,0);
-	
-	private Vector3 halfDelta;
-	private Vector3 quarterDelta;
-	
-	// The zeroPoint will be used to know when the 0,0 of the camera is showing it's 0,0
-	// The onePoint  does the same on the other side.
-	private Vector3 zeroPoint;
-	private Vector3 onePoint;
-
-	private int map_length = 1000;
-	
-	private Vector3 destination;	
-
-	void Update () {
-	    if(target) {	        
-			destination = Vector3.zero;
-			// We want to know if our target will go farther than 50% screen and
-			// less than 25%, in both up and down directions. 
-			// So we'll get the delta of our target and the point of half and quarter the screen. 			
-			halfDelta = target.position - camera.ViewportToWorldPoint(halfScreen);						
-			quarterDelta = target.position - camera.ViewportToWorldPoint(quarterScreen);						
-			
-			// Now we check if we need to move. 
-			// Since we're going pixel based the camera will move in 1 unit ranges (nondecimal).
-			if (halfDelta.x > 0)
-				destination.x = 1;
-			if (halfDelta.y > 0)
-				destination.y = 1;	
-			if (quarterDelta.x < 0)
-				destination.x = -1;
-			if (quarterDelta.y < 0)
-				destination.y = -1;	
-			
-			// Now before we update, we check if we're not on the 0 edge. 
-			// Max Length will be done later on
-			// Plus we only check it if we're moving
-			if (destination != Vector3.zero) {
-				zeroPoint = camera.ViewportToWorldPoint(Vector3.zero);						
-				onePoint = camera.ViewportToWorldPoint(Vector3.one);
-				if (zeroPoint.x <= 0 && destination.x < 0)
-					destination.x = 0;
-				if (onePoint.x >= map_length && destination.x > 0)
-					destination.x = 0;
-			}
-			
-			
-			// FInally we update the camera
-			transform.position = transform.position + destination;
-			
-			// We're moving the gui, altho the best way would be to place it fixed.
-			if (gui) {
-				gui.position = gui.position + destination;	
-			}
-		}		
-	}
-}

File Assets/scripts/GUIController.cs

View file
+using UnityEngine;
+using System.Collections;
+
+public class GUIController : MonoBehaviour
+{
+	public enum GuiAnchor {bottomLeft=0};
+	public GuiAnchor anchor = GuiAnchor.bottomLeft;
+		
+	void Awake ()
+	{
+		// It removes the UI on desktop versions
+		#if UNITY_STANDALONE_WIN || UNITY_STANDALONE_MAC || UNITY_WEBPLAYER
+			Destroy(this.gameObject);
+		#endif
+		
+		// To place this current gui layer on its correct position we'll 
+		// check the camera current 0,0 and set it there.
+		// It is neccesary that the gui objects are always placed under a camera
+		// Since it server for 2 purposes:
+		// a) The gui moves along with it as it's parented. 
+		// 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 = this.gameObject.transform.position.z;
+				this.gameObject.transform.position = zeroPoint;			
+			break;
+		}
+
+	}
+}

File Assets/scripts/InputController.cs

View file
+using UnityEngine;
+using System.Collections;
+using System;
+
+public class InputController : MonoBehaviour {	
+	private const string PlayerGoName = "Player";
+	private const string LeftButtonGoName = "LeftButton";
+	private const string RightButtonGoName = "RightButton";	
+	
+	public enum InputMode {Moving=0};
+	public InputMode InputModeState;
+
+	public enum Key {LeftButton=0, RightButton, AButton, BButton};
+	private int buttonStatus = 0;
+	private int touchStatus = 0;
+
+	private PlayerChar player;
+	private VirtualPad leftButton;
+	private VirtualPad rightButton;
+	private RaycastHit hit;
+	private Ray ray;
+	
+	void Awake() {
+		Debug.Log("input controller");
+		switch (this.InputModeState) {
+			case InputMode.Moving:
+				awakeMove();
+				break;
+		}
+	}
+	
+	void Update() {
+		switch (this.InputModeState) {
+			case InputMode.Moving:
+				manageMove();
+				break;
+		}
+	}
+	
+	void awakeMove() {
+		GameObject playerGo = GameObject.Find(PlayerGoName);
+		if (!playerGo)
+			throw new Exception("Cannot find a gameobject named " + PlayerGoName);
+		this.player = (PlayerChar) playerGo.GetComponent(typeof(PlayerChar));
+
+		#if UNITY_IPHONE || UNITY_ANDROID
+			GameObject leftButtonGo = GameObject.Find(LeftButtonGoName);
+			GameObject rightButtonGo = GameObject.Find(RightButtonGoName);		
+			if (!leftButtonGo)
+				throw new Exception("Cannot find a gameobject named " + LeftButtonGoName );
+			if (!rightButtonGo)
+				throw new Exception("Cannot find a gameobject named " + RightButtonGoName);
+			this.leftButton = (VirtualPad) leftButtonGo.GetComponent(typeof(VirtualPad));
+			this.rightButton = (VirtualPad) rightButtonGo.GetComponent(typeof(VirtualPad));		
+		#endif
+	}
+	
+	void manageMove() {
+		// First we'll analyse the Movement axis, we'll get, -1 for left and 1 for right.
+		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) 
+						touchStatus = -1;
+					else if (hit.transform.gameObject.name == RightButtonGoName)
+						touchStatus = 1;
+				} 
+	        } else if (touch.phase == TouchPhase.Ended) {
+				touchStatus = 0;					
+			}
+	    }
+		if (buttonStatus == 1 || touchStatus == 1) {
+			player.move(PlayerChar.WalkingState.WalkRight);
+			#if UNITY_IPHONE || UNITY_ANDROID
+				leftButton.press(VirtualPad.ButtonStatus.Normal);
+				rightButton.press(VirtualPad.ButtonStatus.Pressed);		
+			#endif
+		} else if (buttonStatus == -1 || touchStatus == -1)  {
+			player.move(PlayerChar.WalkingState.WalkLeft);
+			#if UNITY_IPHONE || UNITY_ANDROID
+				leftButton.press(VirtualPad.ButtonStatus.Pressed);
+				rightButton.press(VirtualPad.ButtonStatus.Normal);
+			#endif
+		} else if (buttonStatus == 0 && touchStatus == 0) {
+			player.move(PlayerChar.WalkingState.Standing);	
+			#if UNITY_IPHONE || UNITY_ANDROID
+				leftButton.press(VirtualPad.ButtonStatus.Normal);
+				rightButton.press(VirtualPad.ButtonStatus.Normal);
+			#endif
+
+		}		
+	}
+}

File Assets/scripts/PlayerChar.cs

View file
         ragePixel = GetComponent<RagePixelSprite>();
     }
 
-	public void move(int direction) {
-		if (direction == (int)WalkingState.WalkRight) {
+	public void move(WalkingState direction) {
+		if (direction == WalkingState.WalkRight) {
             state = WalkingState.WalkRight;
-		} else if (direction == (int)WalkingState.WalkLeft) {
+		} else if (direction == WalkingState.WalkLeft) {
 			state = WalkingState.WalkLeft;									
 		} else {
             state = WalkingState.Standing;			

File Assets/scripts/VirtualPad.cs

View file
 	//Storing the reference to RagePixelSprite -component
     private IRagePixel ragePixel;
 
-	// Enum that manages walking directions, it's the same from the walker
-	// Todo: Unify them
-	public enum WalkingDirection {Standing=0, WalkRight, WalkLeft};
+	// Enum that manages the button status.
+	public enum ButtonStatus {Normal=0, Pressed};
 
-	// Direction the pad will affect
-	public int direction = (int)WalkingDirection.WalkLeft;	
-
-	// The player, it's instantiated on awake
-	private PlayerChar player;
-
-	// The camera, defaults to the main one.
-	public Camera mainCam;
-	
-	// There are used to check the button collision since theres no need to recreate them each frame.
-	Ray ray;
-	RaycastHit hit;
-	
 	void Awake() {
         ragePixel = GetComponent<RagePixelSprite>();
-		GameObject go = GameObject.Find("Sara");
-		this.player = (PlayerChar) go.GetComponent(typeof(PlayerChar));
-		if (!mainCam) {
-			 mainCam = Camera.mainCamera;
-		}	
 	}
 	
-	void Update() {
-
-		// Basic gamepad algortyhm. It uses getmousebuttondown to be compatible with both
-		// Mouse and input touch with less code. The con is that it has no multitouch support.		
-		if (Input.GetMouseButtonDown(0)) {			
-			// We cast a ray and check if it has hit our buttons.
-			ray = Camera.main.ScreenPointToRay(Input.mousePosition);
-		    hit = new RaycastHit();
-		    if (Physics.Raycast(ray, out hit)){
-				// We hit it and move the character in the correct direction				
-				if (hit.transform.gameObject == this.gameObject) {
-					player.move(this.direction);	
-	                ragePixel.PlayNamedAnimation("Pressed", false);
-				}
-			} 
-			
-		} else if (Input.GetMouseButtonUp(0)) {
-			// This is the tricky part, if we dont hit any button it leaves the character standing.
-			// This gets run by each button, so it gets executed twice, its not a good idea to leave it like this
-			// but for now it will do
-			player.move((int)WalkingDirection.Standing);		
-            ragePixel.PlayNamedAnimation("Normal", false);	
-		}		
+	public void press(ButtonStatus status) {
+		if (status == ButtonStatus.Normal)
+            ragePixel.PlayNamedAnimation("Normal", false);				
+		else
+            ragePixel.PlayNamedAnimation("Pressed", false);									
 	}
+	
 }

File LICENSE.MD

View file
+LICENSE
+==============================
+
+Copyright (c) 2012 Pol Cámara
+
+Permission is hereby granted, free of charge, to any
+person obtaining a copy of this software and associated
+documentation files (the "Software"), to deal in the
+Software without restriction, including without limitation
+the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the
+Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions of
+the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
+OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+
+Assets
+==============================
+
+Since there are multiple assets from multiple sources, with different but compatible licenses, i'll be listing them all here.
+
+Sara by Mandi Paugh (http://opengameart.org/content/sara-wizard) (CC-By-Sa)
+
+Bridge Platform from tebruno99 (http://opengameart.org/content/updated-generic-platformer-tiles) (CC-By-Sa)
+
+Clouds by PolCPP (CC-By-Sa)

File Library/AssetImportState

View file
-6;0;-1
+9;0;-1

File Library/EditorUserBuildSettings.asset

Binary file modified.

File Library/InspectorExpandedItems.asset

Binary file modified.

File Library/guidmapper

Binary file modified.

File Library/metadata/68/68e1a4176b6c24dd4a3055666adfd443

Binary file added.

File Library/metadata/78/78504c981f48047dfa4f99ba0529242d

Binary file added.

File Library/metadata/79/799f1a4b0eaf04cf0bc2bcae8ff124eb

Binary file added.

File Library/metadata/85/85e37abe2bd0049b2884d2c4828c4b1c

Binary file added.

File ProjectSettings/InputManager.asset

Binary file modified.

File README.md

View file
 Twisted Potions: Double Trouble
 ==============================
 
-A Unity 3d powered pixel art platformer
-
-License.
-==============================
-
-Copyright (c) <2012> <Pol Cámara>
-
-Permission is hereby granted, free of charge, to any
-person obtaining a copy of this software and associated
-documentation files (the "Software"), to deal in the
-Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the
-Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice
-shall be included in all copies or substantial portions of
-the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
-PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
-OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
-OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-Assets
-==============================
-
-Since there are multiple assets from multiple sources, with different but compatible licenses, i'll be listing them all here.
-
-Sara by Mandi Paugh (http://opengameart.org/content/sara-wizard) (CC-By-Sa)
-Bridge Platform from tebruno99 (http://opengameart.org/content/updated-generic-platformer-tiles) (CC-By-Sa)
-Clouds by PolCPP (CC-By-Sa)
+An open Unity 3d powered pixel art platformer with rpg touches.

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

View file
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2008
+
+Project("{D66321C4-3961-936D-8B9A-321C166F2138}") = "twisted-potions-double-trouble", "Assembly-CSharp-vs.csproj", "{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}"
+EndProject
+Project("{D66321C4-3961-936D-8B9A-321C166F2138}") = "twisted-potions-double-trouble", "Assembly-CSharp-Editor-vs.csproj", "{59F7941D-6875-1925-C4C5-786A44136D76}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}.Release|Any CPU.Build.0 = Release|Any CPU
+		{59F7941D-6875-1925-C4C5-786A44136D76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{59F7941D-6875-1925-C4C5-786A44136D76}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{59F7941D-6875-1925-C4C5-786A44136D76}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{59F7941D-6875-1925-C4C5-786A44136D76}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+															GlobalSection(MonoDevelopProperties) = preSolution
+		StartupItem = Assembly-CSharp.csproj
+		Policies = $0
+		$0.TextStylePolicy = $1
+		$1.inheritsSet = null
+		$1.scope = text/x-csharp
+		$0.CSharpFormattingPolicy = $2
+		$2.inheritsSet = Mono
+		$2.inheritsScope = text/x-csharp
+		$2.scope = text/x-csharp
+		$0.TextStylePolicy = $3
+		$3.FileWidth = 120
+		$3.TabWidth = 4
+		$3.EolMarker = Unix
+		$3.inheritsSet = Mono
+		$3.inheritsScope = text/plain
+		$3.scope = text/plain
+	EndGlobalSection
+
+EndGlobal

File twisted-potions-double-trouble.sln

View file
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2008
+
+Project("{D66321C4-3961-936D-8B9A-321C166F2138}") = "twisted-potions-double-trouble", "Assembly-CSharp.csproj", "{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}"
+EndProject
+Project("{D66321C4-3961-936D-8B9A-321C166F2138}") = "twisted-potions-double-trouble", "Assembly-CSharp-Editor.csproj", "{59F7941D-6875-1925-C4C5-786A44136D76}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{165C50A8-B817-B6A6-C1B9-9BF7C279A4A4}.Release|Any CPU.Build.0 = Release|Any CPU
+		{59F7941D-6875-1925-C4C5-786A44136D76}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{59F7941D-6875-1925-C4C5-786A44136D76}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{59F7941D-6875-1925-C4C5-786A44136D76}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{59F7941D-6875-1925-C4C5-786A44136D76}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+														GlobalSection(MonoDevelopProperties) = preSolution
+		StartupItem = Assembly-CSharp.csproj
+		Policies = $0
+		$0.TextStylePolicy = $1
+		$1.inheritsSet = null
+		$1.scope = text/x-csharp
+		$0.CSharpFormattingPolicy = $2
+		$2.inheritsSet = Mono
+		$2.inheritsScope = text/x-csharp
+		$2.scope = text/x-csharp
+		$0.TextStylePolicy = $3
+		$3.FileWidth = 120
+		$3.TabWidth = 4
+		$3.EolMarker = Unix
+		$3.inheritsSet = Mono
+		$3.inheritsScope = text/plain
+		$3.scope = text/plain
+	EndGlobalSection
+
+EndGlobal

File twisted-potions-double-trouble.userprefs

View file
+<Properties>
+  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
+  <MonoDevelop.Ide.Workbench ActiveDocument="GuiController.cs">
+    <Files>
+      <File FileName="GuiController.cs" Line="6" Column="2" />
+    </Files>
+  </MonoDevelop.Ide.Workbench>
+  <MonoDevelop.Ide.DebuggingService.Breakpoints>
+    <BreakpointStore />
+  </MonoDevelop.Ide.DebuggingService.Breakpoints>
+  <MonoDevelop.Ide.DebuggingService.PinnedWatches />
+</Properties>