Exemple #1
0
    private void CheckUnit()
    {
        PopDown();

        if (Input.GetMouseButtonDown(1))
        {
            _state = GameState.Select;
            _select.Highlight(false);
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                HexTile tile = hit.collider.GetComponentInParent <HexTile>();

                if (tile)
                {
                    if (_select.CheckAPath(tile))
                    {
                        _select.moveTo(tile);
                        _select.Highlight(false);
                        _select = null;
                        _state  = GameState.Select;
                    }
                }
            }
        }
    }
Exemple #2
0
    private void Build()
    {
        PopDown();
        if (Input.GetMouseButtonDown(1))
        {
            _state = GameState.Select;
            _select.Highlight(false);
        }

        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                HexTile tile = hit.collider.GetComponentInParent <HexTile>();

                if (tile)
                {
                    if (_select.CheckAPath(tile))
                    {
                        tile.InstantiateHexObject(blueprints[_buildInfra]);

                        AddCoin(currentTeam, -1 * _costs[_buildInfra]);
                        _select.Highlight(false);
                        _select = null;
                        _state  = GameState.Select;
                    }
                }
            }
        }
    }
Exemple #3
0
    public void EndTurn()
    {
        currentTeam++;
        if (currentTeam == teamNumber)
        {
            currentTeam = 0;
        }

        if (!hqs[currentTeam])
        {
            currentTeam++;
            if (currentTeam == teamNumber)
            {
                currentTeam = 0;
            }
        }

        for (int i = 0; i < allGameObjects.Count; i++)
        {
            IEdifice edifice = allGameObjects[i].GetComponent <IEdifice>();
            edifice.AfterTurn();
        }

        HighlightObjects();

        _state = GameState.Select;
    }
Exemple #4
0
    private void SelectEdifice()
    {
        PopDown();
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                HexTile  tile    = hit.collider.GetComponentInParent <HexTile>();
                IEdifice edifice = hit.collider.GetComponentInParent <IEdifice>();

                if (tile)
                {
                    if (tile.edifice != null)
                    {
                        _select = tile.edifice;
                    }
                }

                if (edifice != null)
                {
                    _select = edifice;
                }
            }


            if (_select != null)
            {
                if (_select.team != currentTeam)
                {
                    return;
                }

                if (!_select.active)
                {
                    return;
                }

                if (_select is Infra)
                {
                    _state = GameState.CheckInfra;
                    return;
                }

                else if (_select is Unit)
                {
                    _select.Highlight(true);
                    _state = GameState.CheckUnit;
                    return;
                }
            }
        }
    }
Exemple #5
0
    public void InstantiateHexObject(GameObject _obj)
    {
        GameObject obj = Instantiate(_obj);

        Manager.allGameObjects.Add(obj);
        IEdifice edifice = obj.GetComponentInChildren <IEdifice>();

        edifice.SetCurrent(this);
        edifice.team = Manager.currentTeam;
        //edifice.HighlightThis(true);
    }
Exemple #6
0
 private void HighlightObjects()
 {
     for (int i = 0; i < allGameObjects.Count; i++)
     {
         IEdifice edifice = allGameObjects[i].GetComponent <IEdifice>();
         if (edifice.team == currentTeam)
         {
             edifice.HighlightThis(true);
         }
         else
         {
             edifice.HighlightThis(false);
         }
     }
 }