示例#1
0
    private void Update()
    {
        if (mousedOver)
        {
            if (isValidPlaceLocation())
            {
                setTileMaterial(tileMouseOverMaterial);
                //Left click will change the tile to one that blocks hero movement
                if (Input.GetMouseButtonDown(0))
                {
                    // create building, set to blocking
                    isBlocking = true;
                    getBuildingStatus();

                    if (currentBuilding != null)
                    {
                        setTileMaterial(tileDefaultMaterial);
                    }

                    // update enemies paths.
                    foreach (GameObject enemy in GameController.enemies)
                    {
                        enemy.GetComponent <EnemyBehavior>().updateMyPath();
                    }

                    // update global starting path
                    GameController.currentPath.Clear();
                    GameController.currentPath = PathingLogic_Static.GetPath();
                }
            }
            else
            {
                if (currentBuilding == null)
                {
                    setTileMaterial(tileMouseOverMaterialBadLocation);
                }
            }

            //Right click will change the tile to one that does not blocks hero movement
            if (Input.GetMouseButtonDown(1))
            {
                if (currentBuilding != null)
                {
                    isBlocking = false;
                    getBuildingStatus();
                    foreach (GameObject enemy in GameController.enemies)
                    {
                        enemy.GetComponent <EnemyBehavior>().updateMyPath();
                    }
                    GameController.currentPath.Clear();
                    GameController.currentPath = PathingLogic_Static.GetPath();
                }
            }
        }
    }
示例#2
0
    // Start is called before the first frame update
    void Start()
    {
        for (int i = 1; i <= numRows; i++)
        {
            for (int j = 1; j <= numCols; j++)
            {
                // create new tile
                GameObject tileIteration = Instantiate(tile);
                // get its logic object
                TileBehavior tileBehavior = tileIteration.GetComponent <TileBehavior>();
                // set row and col
                tileBehavior.setRow(i);
                tileBehavior.setCol(j);
                // set position
                setTilePosition(tileIteration, i, j);
                // put in map for reference
                GameController.positionMap.Add(new Vector2(i, j), tileBehavior);
            }
        }

        //HeroPathing pathing = new HeroPathing();
        GameController.currentPath = PathingLogic_Static.GetPath();
    }
示例#3
0
 public void updateMyPath()
 {
     myCurrentPath = PathingLogic_Static.GetPath(getNextTileInPath());
     currentPlaceInTileSequence = -1;
     setNextMoveToLocation();
 }