Skip to content

Instantly share code, notes, and snippets.

@AndrewWeston9
Created October 6, 2017 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewWeston9/2b6a1c82182e71b5adf26e73578b2a18 to your computer and use it in GitHub Desktop.
Save AndrewWeston9/2b6a1c82182e71b5adf26e73578b2a18 to your computer and use it in GitHub Desktop.
PlayerMove.cs Snippet: functions for resource changes, communicating with PlayerState class.
// Current block type selected by the player to be placed.
int currentBlockType = 1;
/// Is the player flag placed in the world.
public bool playerFlagPlaced = false;
bool inTrigger = false;
GameObject flagShortest;
/// Timer for flag check
int flagTimer = 0;
bool checkFlagRangeLast = false;
PlayerState playerState;
public Animator anim;
public float speed = 2.0f;
public float rotationSpeed = 75.0f;
int timer = 0;
public List<float> resourceLevelsPMove;
/// Take Resources action.
if (Input.GetKeyDown (KeyCode.G) && !checkFlagRange())
{
PlayerState pstate = gameObject.GetComponent<PlayerState> ();
pstate.takeResource ();
//Debug.LogError ("Taking Resources from playermove!!!");
}
public void adjustResource()
{
playerState.expendResorce (currentBlockType, -0.1f);
}
public bool checkResource()
{
if(playerState.getResource (currentBlockType) >= 0.1f)
{
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment