Last active
October 6, 2017 06:45
-
-
Save AndrewWeston9/725f332200b5ba15b57297fcee46d2c3 to your computer and use it in GitHub Desktop.
PlayerMove.cs Snippet: Placing a block in the world.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (Input.GetKeyDown(KeyCode.LeftControl) && (isGrounded () || attached)) | |
{ | |
if (playerFlagPlaced == false || currentBlockType != 10) | |
{ | |
if(!checkFlagRange() && (checkResource() || currentBlockType == 10 || currentBlockType == 1)) | |
{ | |
int px = (int)(playerpos.x + 0.5f); | |
int py = Math.Max ((int)(playerpos.y), (int)WorldManager.minLevelHeight); | |
int pz = (int)(playerpos.z + 0.5f); | |
Debug.Log ("place at " + px + " " + pz + " " + py); | |
if (attached) { | |
localWorld.placeBlock (px, pz, py, currentBlockType); | |
} else { | |
localWorld.placeBlock (px, pz, py + 1.0f, currentBlockType); | |
} | |
//Quest Manager log | |
QuestManager.qManager.AddQItem ("Place a block", 1); | |
y = 0.2f; | |
if (currentBlockType == 10) { | |
playerFlagPlaced = true; | |
transform.Translate (0, 3.0f, 0); | |
//Quest Manager log | |
QuestManager.qManager.AddQItem ("Place a flag", 1); | |
} else { | |
transform.Translate (0, 1.5f, 0); | |
} | |
adjustResource(); | |
attached = false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment