Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (Vector3.Distance(transform.position, grid.CalcWorldPos(unitPositionX, transform.position.y, unitPositionY)) < 0.05f)
        {
            MoveNextTile();
            ActionPolicy();
            if (!exploding)
            {
                unitBusy = false;
            }
        }

        unitPositionText = "l" + unitPositionX.ToString() + "c" + unitPositionY.ToString();

        transform.position = Vector3.Lerp(transform.position, grid.CalcWorldPos(unitPositionX, transform.position.y, unitPositionY), speed * Time.deltaTime);
    }
Пример #2
0
    public void SpawnUnit(Color32 color, Tile tile)
    {
        foreach (PlayersLibrary pl in playerLibrary)
        {
            if (color.Equals(pl.color))
            {
                Vector3    startPosition = grid.CalcWorldPos(tile.tileX, 1, tile.tileY);
                GameObject gameObj       = Instantiate(pl.prefab, startPosition, Quaternion.identity) as GameObject;

                MeshRenderer objMesh = gameObj.GetComponent <MeshRenderer>();
                if (pl.material != null)
                {
                    objMesh.material = pl.material;
                }

                gameObj.transform.parent = this.transform;
                gameObj.name             = pl.name;
                gameObj.GetComponent <Unit>().unitPositionX    = tile.tileX;
                gameObj.GetComponent <Unit>().unitPositionY    = tile.tileY;
                gameObj.GetComponent <Unit>().unitPositionText = "l" + tile.tileX.ToString() + "c" + tile.tileY.ToString();
                gameObj.GetComponent <Unit>().moveSpeed        = pl.actionPoints;
                gameObj.GetComponent <Unit>().stench           = pl.stench;
                gameObj.GetComponent <Unit>().speed            = pl.speed;

                if (gameObj.GetComponent <Minotaur>())
                {
                    grid.problemObjects += "\n\t\t" + gameObj.name + " - minotaur\n\t\t";
                }
                if (gameObj.GetComponent <Player>())
                {
                    grid.problemObjects += "\n\t\t" + gameObj.name + " - player\n\t\t";
                    grid.initialState.Add("atTile", gameObj.name, gameObj.GetComponent <Unit>().unitPositionText);
                    grid.initialState.Add("isAlive", gameObj.name);
                }
            }
        }

        turnController.GetUnits();
    }
Пример #3
0
 void Update()
 {
     Collider[] tilesInSpace = Physics.OverlapSphere(grid.CalcWorldPos(GetComponent <Unit> ().unitPositionX, transform.position.y - 1, GetComponent <Unit> ().unitPositionY), 0.1f);
     for (int i = 0; i < tilesInSpace.Length; i++)
     {
         if (tilesInSpace [i].GetComponent <Tile> ().playerNear < 99)
         {
             engaged = true;
         }
         else
         {
             engaged = false;
         }
     }
     if (minotaurLife == 0)
     {
         Destroy(this.gameObject);
         GetComponent <Unit> ().HideStench();
     }
 }