Exemplo n.º 1
0
 private void turnUpdate()
 {
     if (playerScript.stepCounter <= 0 && !playerScript.getIsLerping())
     {
         for (int i = 0; i < turnMeters.Count; i++)
         {
             turnMeters[i] += playerScript.getSpeed(i);
             if (turnMeters[i] >= 10.0f)
             {
                 playerScript.newTurn(i);
                 GameObject[] listOfPickUp = GameObject.FindGameObjectsWithTag("PickUps");
                 foreach (GameObject pickUp in listOfPickUp)
                 {
                     Destroy(pickUp);
                 }
                 for (int x = 0; x < gridWidth; x++)
                 {
                     for (int y = 0; y < gridHeight; y++)
                     {
                         int pickUpValue = Random.Range(0, 3);
                         if (x == gridWidth / 2 && y == gridHeight / 2) //create Player in middle;
                         {
                             continue;
                         }
                         GameObject newPickUp = null;
                         newPickUp = Instantiate(pickUps, new Vector3(x * cellSize + cellSize * 0.5f, y * cellSize + cellSize * 0.5f), new Quaternion(0f, 0f, 0f, 0f));
                         PickUpBehavior pickUpScript = newPickUp.GetComponent <PickUpBehavior>();
                         pickUpScript.setPickUpType((PickUpType)pickUpValue);
                         pickUpScript.setSprite(pickUpValue);
                     }
                 }
                 attackCounter = 0;
                 defendCounter = 0;
                 healCounter   = 0;
                 turnMeters[i] = 0.0f;
             }
         }
     }
 }
Exemplo n.º 2
0
 // Start is called before the first frame update
 void Start()
 {
     initailizeIconList();
     finishFlagPos = finishFlagIcon.transform.position;
     for (int x = 0; x < gridWidth; x++)
     {
         for (int y = 0; y < gridHeight; y++)
         {
             int pickUpValue = Random.Range(0, 3);
             if (x == gridWidth / 2 && y == gridHeight / 2) //create Player in middle;
             {
                 GameObject playerObject = null;
                 playerObject = Instantiate(player, new Vector3(x * cellSize + cellSize * 0.5f, y * cellSize + cellSize * 0.5f), new Quaternion(0f, 0f, 0f, 0f));
                 playerScript = playerObject.GetComponent <PlayerBehavior>();
                 continue;
             }
             GameObject newPickUp = null;
             newPickUp = Instantiate(pickUps, new Vector3(x * cellSize + cellSize * 0.5f, y * cellSize + cellSize * 0.5f), new Quaternion(0f, 0f, 0f, 0f));
             PickUpBehavior pickUpScript = newPickUp.GetComponent <PickUpBehavior>();
             pickUpScript.setPickUpType((PickUpType)pickUpValue);
             pickUpScript.setSprite(pickUpValue);
         }
     }
 }