예제 #1
0
 private void GridCreated()
 {
     transform.position = GameManager.I.gridController.GetCellWorldPosition((int)startPos.x, (int)startPos.y);
     startCell          = GameManager.I.gridController.Cells[(int)startPos.x, (int)startPos.y];
     lastCell           = GameManager.I.gridController.Cells[(int)lastPos.x, (int)lastPos.y];
     path = this.FindPath(startCell, lastCell, new PathFindingSettings());
 }
예제 #2
0
 public Enemy GetEnemyInCell()
 {
     if (this.UniqueID != "")
     {
         CellDoomstock cell = null;
         if (GameManager.I.gridController.GetBuildingPositionByUniqueID(UniqueID).x != -1)
         {
             cell = GameManager.I.gridController.Cells[(int)GameManager.I.gridController.GetBuildingPositionByUniqueID(UniqueID).x, (int)GameManager.I.gridController.GetBuildingPositionByUniqueID(UniqueID).y];
         }
         if (cell != null)
         {
             List <Enemy>         returnlist = new List <Enemy>();
             List <CellDoomstock> list       = GameManager.I.gridController.GetNeighboursStar(cell);
             foreach (var item in list)
             {
                 if (item.EnemiesInCell.Count > 0)
                 {
                     returnlist.Add(item.EnemiesInCell.First());
                 }
             }
             if (returnlist.Count > 0)
             {
                 return(returnlist.First());
             }
         }
     }
     return(null);
 }
예제 #3
0
    /// <summary>
    /// Distrugge il building.
    /// </summary>
    public void destroyMe()
    {
        if (isAlive)
        {
            isAlive = false;
            if (OnDestroy != null)
            {
                OnDestroy(this);
            }
            CellDoomstock cell = GameManager.I.gridController.Cells[(int)Data.GetGridPosition().x, (int)Data.GetGridPosition().y];
            cell.SetStatus(CellDoomstock.CellStatus.Debris, cell.building);
            if (Data.ID != "Casa")
            {
                Data.RemoveAllPopulationFromBuilding();
            }
            TimeEventManager.OnEvent -= OnUnitEvent;
            SetBuildingStatus(BuildingState.Destroyed);

            List <Transform> myobject = gameObject.GetComponentsInChildren <Transform>().ToList();
            myobject.Remove(transform);
            if (Data.ID == "Meraviglia")
            {
                GameManager.I.OnMeravigliaDestroyed();
            }
            foreach (Transform go in myobject)
            {
                go.gameObject.SetActive(false);
            }
            CurrentMesh.mesh = Macerie;
            gameObject.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
            transform.eulerAngles           = new Vector3(90, 20, 0);
        }
    }
예제 #4
0
    /// <summary>
    /// Attacca il prossimo step se è presente un building.
    /// </summary>
    void AttackNextStep()
    {
        CellDoomstock nextStep = CurrentPath[CurrentNodeIndex] as CellDoomstock;

        if (Type == enemyType.Tank || Type == enemyType.Combattenti)
        {
            if (nextStep.isTraversable == false)
            {
                if (nextStep.building)
                {
                    CurrentTarget = null;
                    NearTarget    = nextStep.building;
                    Attack(nextStep.building);
                }
            }
        }
        //else
        //{

        //    if (nextStep.isTraversable == false)
        //    {
        //        resetTarget();
        //        currentState = enemyState.Searching;


        //    }
        //}
    }
예제 #5
0
    /// <summary>
    /// carica le possibili scelte selezionabili.
    /// </summary>
    public override void LoadSelections()
    {
        PossibiliScelteAttuali.Clear();
        switch (ScelteFatte.Count)
        {
        case 0:
            if (firstLevelSelections != null)
            {
                foreach (ISelectable selectable in firstLevelSelections)
                {
                    PossibiliScelteAttuali.Add(selectable);
                }
            }
            break;

        case 1:
            CellDoomstock cell = GameManager.I.gridController.Cells[CurrentPlayer.XpositionOnGrid, CurrentPlayer.YpositionOnGrid];
            switch (ScelteFatte[0].UniqueID)
            {
            case " + Building":

                foreach (BuildingData building in CurrentPlayer.BuildingsDataPrefabs)
                {
                    BuildingData newBuildingInstance = Instantiate <BuildingData>(building);
                    //TODO : check del terreno con cambio di Layer
                    PossibiliScelteAttuali.Add(newBuildingInstance);
                }
                break;
            //case "Destroy":
            //    foreach (BuildingView item in GameManager.I.buildingManager.GetAllBuildingInScene())
            //    {
            //        cell.building = item.Data;
            //        PossibiliScelteAttuali.Add(item.Data);
            //    }
            //    DoAction();
            //    break;

            //case " Info ":

            //    break;
            //case " - Debris":
            //    DoAction();
            //    break;
            //case " Prendi ":
            //    DoAction();
            //    break;
            default:
                break;
            }
            break;


        default:
            DoAction();
            return;
        }
        RefreshItemList();
        IndiceDellaSelezioneEvidenziata = 0;
    }
예제 #6
0
    public void ShowiInformation(MessageLableType _message, CellDoomstock _worldPosition, bool isImmediate = false, string iconToGet = null)
    {
        float delay = 0;

        if (!isImmediate)
        {
            delay = Random.Range(MinRange, MaxRange);
            ;
        }
        StartCoroutine(ShowMessage(delay, _message, _worldPosition, iconToGet));
    }
예제 #7
0
 public void DesotryUiInformation(CellDoomstock _cell)
 {
     UiInformation[] uiToReturn = FindObjectsOfType <UiInformation>();
     foreach (var item in uiToReturn)
     {
         if (item.cell == _cell && item.MessageType == "Stuck")
         {
             item.transform.DOMove(new Vector3(Target.transform.position.x, Target.transform.position.y, Target.transform.position.z), 1f).SetEase(Ease.InOutCirc, 1).OnComplete(() =>
             {
                 Destroy(item.gameObject);
             });
             item.transform.DOScale(0, 0.2f).SetDelay(0.8f);
         }
     }
 }
예제 #8
0
    /// <summary>
    /// abilità dei player
    /// </summary>
    /// <param name="cell"></param>
    void Ability(CellDoomstock cell)
    {
        switch (ID)
        {
        case "Sindaco":
            if (GameManager.I.GetResourceDataByID("Faith").Value >= RiparationCost && cell.building.ID != "Foresta")
            {
                GameManager.I.GetResourceDataByID("Faith").Value -= RiparationCost;
                cell.building.BuildingLife = cell.building.InitialLife;
                cell.building.GetParticlesEffect();
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.Reparing, GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid], true);
            }
            break;

        case "Esercito":
            if (GameManager.I.GetResourceDataByID("Faith").Value >= DemolitionCost && cell.building.ID != "Foresta")
            {
                if (cell.building.BuildingLife == cell.building.InitialLife)
                {
                    if (cell.building.CurrentState != BuildingState.Construction)
                    {
                        DestroyBuilding(cell.building.UniqueID);
                        GameManager.I.GetResourceDataByID("Faith").Value -= DemolitionCost;
                        GameManager.I.messagesManager.ShowiInformation(MessageLableType.Destroing, GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid], true);
                    }
                }
            }
            break;

        case "Clero":
            if (GameManager.I.GetResourceDataByID("Faith").Value >= CleroAbilityCost)
            {
                GameManager.I.GetResourceDataByID("Faith").Value -= CleroAbilityCost;
                foreach (var item in cell.building.BuildingResources)
                {
                    item.Value = item.Limit;
                    GameManager.I.buildingManager.GetBuildingView(cell.building.UniqueID).SetBuildingStatus(BuildingState.Ready);
                }
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.Miracle, GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid], true);
            }
            break;

        default:
            break;
        }
        GameManager.I.uiManager.SetFaithTextColor();
    }
예제 #9
0
    public CellDoomstock RandomSpawnPosition()
    {
        CellDoomstock        randomPos = new CellDoomstock();
        List <CellDoomstock> nullCells = new List <CellDoomstock>();


        foreach (var cell in GameManager.I.gridController.Cells)
        {
            if (cell.Type == CellDoomstock.CellType.Nullo)
            {
                nullCells.Add(cell);
            }
        }
        int random = Random.Range(0, nullCells.Count);

        randomPos = nullCells[random];
        return(randomPos);
    }
예제 #10
0
    IEnumerator SpawnEnemy(float waitTime)
    {
        for (int i = 0; i < TankToSpawn; i++)
        {
            CellDoomstock pos  = RandomSpawnPosition();
            Enemy         tank = Instantiate(TankPrefab, GameManager.I.gridController.GetCellWorldPosition((int)pos.GetGridPosition().x, (int)pos.GetGridPosition().y), TankPrefab.transform.rotation);
            tank.Init(pos);

            yield return(new WaitForSeconds(waitTime));
        }

        for (int i = 0; i < CombattentiToSpawn; i++)
        {
            CellDoomstock pos         = RandomSpawnPosition();
            Enemy         combattente = Instantiate(CombattentiPrefab, GameManager.I.gridController.GetCellWorldPosition((int)pos.GetGridPosition().x, (int)pos.GetGridPosition().y), CombattentiPrefab.transform.rotation);
            combattente.Init(pos);
            yield return(new WaitForSeconds(waitTime));
        }
    }
예제 #11
0
    //Renderer rend;
    //public Material[] Color;

    public void Init(CellDoomstock _data)
    {
        data = _data;
        data.OnDataChanged  = null;
        data.OnDataChanged += OnDataChanged;
        //rend = GetComponentInChildren<Renderer>();
        //rend.enabled = true;
        //if (data.Status == CellDoomstock.CellStatus.Hole)
        //{
        //    rend.material = Color[0];
        //}
        ////else if (data.Cost > 5) {
        ////    rend.material = Color[1];
        ////}
        //else
        //{
        //    return;
        //}
    }
예제 #12
0
    IEnumerator ShowMessage(float waitTime, MessageLableType _message, CellDoomstock _worldPosition, string iconToGet = null)
    {
        yield return(new WaitForSeconds(waitTime));

        UiInformation info = Instantiate(uiInformationPrefab,
                                         new Vector3(_worldPosition.GetWorldPosition().x,
                                                     _worldPosition.GetWorldPosition().y,
                                                     _worldPosition.GetWorldPosition().z + 0.5f), this.transform.rotation);

        info.cell = _worldPosition;
        switch (_message)
        {
        case MessageLableType.FoodProduction:
        case MessageLableType.FaithProduction:
        case MessageLableType.WoodProduction:
        case MessageLableType.SpiritProduction:
        case MessageLableType.StoneProduction:
        case MessageLableType.Death:
        case MessageLableType.Birth:
        case MessageLableType.RemovePopulation:
        case MessageLableType.AddPopulation:
        case MessageLableType.Reparing:
        case MessageLableType.Destroing:
        case MessageLableType.Miracle:
            info.ShowMessagePop_up(_message, iconToGet);
            info.MessageType = "PopUp";
            break;

        case MessageLableType.LimitFood:
        case MessageLableType.LimitFaith:
        case MessageLableType.LimitWood:
        case MessageLableType.LimitSpirit:
        case MessageLableType.LimitStone:
        case MessageLableType.LimitPopulation:
        case MessageLableType.GetMacerie:
            info.ShowMessageStuck(_message);
            info.MessageType = "Stuck";
            break;

        default:
            break;
        }
    }
예제 #13
0
    public void Init(CellDoomstock _startPos)
    {
        //transform.position = new Vector3(_startPos.GetWorldPosition().x, _startPos.GetWorldPosition().y - 0.5f, _startPos.GetWorldPosition().z);
        _animator = GetComponent <Animator>();
        switch (Type)
        {
        case enemyType.Tank:
            pathFindingSettings = PathFindingSettings.Tank;
            break;

        case enemyType.Combattenti:
            pathFindingSettings = PathFindingSettings.Tank;
            break;
        }
        transform.DOMove(new Vector3(_startPos.GetWorldPosition().x, _startPos.GetWorldPosition().y - 0.5f, _startPos.GetWorldPosition().z - 0.4f), MovementSpeed).OnComplete(() =>
        {
            CurrentPosition = _startPos;
        });
    }
예제 #14
0
        protected virtual GameObject CreateGridTileView(Vector3 tilePosition, T cellData)
        {
            CellDoomstock cell = cellData as CellDoomstock;
            GameObject    newTile;

            switch (cell.Type)
            {
            case CellDoomstock.CellType.Forest:
                newTile      = Instantiate <GameObject>(TilePrefab[2], tilePosition, Quaternion.identity, this.transform);
                newTile.name = "Cell[" + tilePosition.x + "," + tilePosition.y + "]";
                return(newTile);

            case CellDoomstock.CellType.Secco:
                newTile      = Instantiate <GameObject>(TilePrefab[4], tilePosition, Quaternion.identity, this.transform);
                newTile.name = "Cell[" + tilePosition.x + "," + tilePosition.y + "]";
                return(newTile);

            case CellDoomstock.CellType.Erba:
                newTile      = Instantiate <GameObject>(TilePrefab[0], tilePosition, Quaternion.identity, this.transform);
                newTile.name = "Cell[" + tilePosition.x + "," + tilePosition.y + "]";
                return(newTile);

            case CellDoomstock.CellType.Roccia:
                newTile      = Instantiate <GameObject>(TilePrefab[3], tilePosition, Quaternion.identity, this.transform);
                newTile.name = "Cell[" + tilePosition.x + "," + tilePosition.y + "]";
                return(newTile);

            case CellDoomstock.CellType.Nullo:
                newTile      = Instantiate <GameObject>(TilePrefab[1], tilePosition, Quaternion.identity, this.transform);
                newTile.name = "Cell[" + tilePosition.x + "," + tilePosition.y + "]";
                return(newTile);

            case CellDoomstock.CellType.Meraviglia:
                newTile      = Instantiate <GameObject>(TilePrefab[0], tilePosition, Quaternion.identity, this.transform);
                newTile.name = "Cell[" + tilePosition.x + "," + tilePosition.y + "]";
                return(newTile);

            default:
                break;
            }
            return(null);
        }
예제 #15
0
    /// <summary>
    /// esegue un'azione alla selezione.
    /// </summary>
    public override void DoAction()
    {
        CellDoomstock cell = GameManager.I.gridController.Cells[CurrentPlayer.XpositionOnGrid, CurrentPlayer.YpositionOnGrid];

        switch (ScelteFatte[0].UniqueID)
        {
        case " + Building":
            CurrentPlayer.DeployBuilding(ScelteFatte[1] as BuildingData);
            break;
        //case "Destroy":
        //    CurrentPlayer.DestroyBuilding(cell.building.UniqueID);
        //    break;

        //case " Info ":
        //    break;
        //case " - Debris":
        //    CurrentPlayer.RemoveBuildingDebris(cell.building);
        //    break;

        default:
            break;
        }
        Close();
    }
예제 #16
0
    void OnUnitEvent(TimedEventData _eventData)
    {
        switch (_eventData.ID)
        {
        case "Production":
            CellDoomstock cell = null;
            if (Data.CurrentState == BuildingState.Producing && Data.ID != "Foresta" && Data.ID != "Meraviglia")
            {
                cell = GameManager.I.gridController.Cells[(int)Data.GetGridPosition().x, (int)Data.GetGridPosition().y];
                foreach (var res in Data.BuildingResources)
                {
                    res.Value += (int)(Data.Population.Count * 1);
                    LimitReached(res);
                    switch (res.ID)
                    {
                    case "Faith":
                        GameManager.I.messagesManager.ShowiInformation(MessageLableType.FaithProduction, cell, true, "1");
                        break;

                    case "Stone":
                        GameManager.I.messagesManager.ShowiInformation(MessageLableType.StoneProduction, cell, true, "1");
                        break;

                    case "Food":
                        GameManager.I.messagesManager.ShowiInformation(MessageLableType.FoodProduction, cell, true, "1");
                        break;

                    default:
                        break;
                    }
                }
            }
            else if (Data.CurrentState == BuildingState.Producing && Data.ID == "Foresta")
            {
                cell = GameManager.I.gridController.Cells[(int)Data.GetGridPosition().x, (int)Data.GetGridPosition().y];
                foreach (var res in Data.BuildingResources)
                {
                    res.Value += 1;
                    LimitReached(res);
                    if (res.ID == "Wood")
                    {
                        GameManager.I.messagesManager.ShowiInformation(MessageLableType.WoodProduction, cell, true, "1");
                    }
                }
            }
            break;

        case "Delay":
            if (Data.CurrentState == BuildingState.Waiting)
            {
                Data.Delay++;
                if (Data.Population.Count > 0)
                {
                    SetBuildingStatus(BuildingState.Producing);
                }
                if (Data.Delay >= Data.DelayLimit)
                {
                    SetBuildingStatus(BuildingState.Built);
                }
            }
            break;

        default:
            break;
        }
    }
예제 #17
0
    /// <summary>
    /// Controlla se vengono premuti degli input da parte del player.
    /// </summary>
    void CheckInputStatus(InputStatus _inputStatus)
    {
        if (currentMenu == null)

        {
            if (_inputStatus.Y == ButtonState.Released && GameManager.I.OnMeravigliaDestroyed() == true)
            {
                currentMenu    = OpenEndGameMenu();
                Time.timeScale = 0.00000000001f;
                if (currentMenu.PossibiliScelteAttuali.Count < 1)
                {
                    currentMenu.Close();
                }
            }
            CellDoomstock cell = GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid];
            if (_inputStatus.X == ButtonState.Pressed)
            {
                if (cell.building && cell.building.CurrentState != BuildingState.Destroyed)
                {
                    Ability(cell);
                }
            }
            // controllo che la levetta sia stata rilasciata nei due sensi o quasi
            if (_inputStatus.LeftThumbSticksAxisY <= 0.2 && _inputStatus.LeftThumbSticksAxisY >= -0.2)
            {
                isReleasedVertical = true;
            }
            if (_inputStatus.LeftThumbSticksAxisX <= 0.2 && _inputStatus.LeftThumbSticksAxisX >= -0.2)
            {
                isReleasedHorizontal = true;
            }

            if ((_inputStatus.DPadUp == ButtonState.Pressed || _inputStatus.LeftThumbSticksAxisY >= 0.5) && isReleasedVertical) // GO UP
            {
                GameManager.I.gridController.MoveToGridPosition(XpositionOnGrid, YpositionOnGrid + 1, this);
                isReleasedVertical = false;
            }
            if ((_inputStatus.DPadLeft == ButtonState.Pressed || _inputStatus.LeftThumbSticksAxisX <= -0.5) && isReleasedHorizontal)  // GO LEFT
            {
                GameManager.I.gridController.MoveToGridPosition(XpositionOnGrid - 1, YpositionOnGrid, this);
                isReleasedHorizontal = false;
            }
            if ((_inputStatus.DPadDown == ButtonState.Pressed || _inputStatus.LeftThumbSticksAxisY <= -0.5) && isReleasedVertical) // GO DOWN
            {
                GameManager.I.gridController.MoveToGridPosition(XpositionOnGrid, YpositionOnGrid - 1, this);
                isReleasedVertical = false;
            }
            if ((_inputStatus.DPadRight == ButtonState.Pressed || _inputStatus.LeftThumbSticksAxisX >= 0.5) && isReleasedHorizontal) // GO RIGHT
            {
                GameManager.I.gridController.MoveToGridPosition(XpositionOnGrid + 1, YpositionOnGrid, this);
                isReleasedHorizontal = false;
            }
            if (_inputStatus.A == ButtonState.Pressed) // SELECT
            {
                if (cell.building)
                {
                    switch (cell.building.CurrentState)
                    {
                    case BuildingState.Construction:
                        return;

                    case BuildingState.Built:
                    case BuildingState.Producing:
                        if (CanClick())
                        {
                            foreach (var item in cell.building.BuildingResources)
                            {
                                GameManager.I.buildingManager.GetBuildingView(cell.building.UniqueID).LimitReached(item);
                            }
                            AddResourceOnClick(cell.building, cell);
                            foreach (var item in cell.building.BuildingResources)
                            {
                                GameManager.I.buildingManager.GetBuildingView(cell.building.UniqueID).LimitReached(item);
                            }
                        }
                        break;

                    case BuildingState.Ready:
                        if (CanClick())
                        {
                            GameManager.I.messagesManager.DesotryUiInformation(cell);
                            foreach (var item in cell.building.BuildingResources)
                            {
                                GameManager.I.GetResourceDataByID(item.ID).Value += item.Limit;
                                switch (item.ID)
                                {
                                case "Food":
                                    GameManager.I.soundManager.GetFoodSound();
                                    break;

                                case "Wood":
                                    GameManager.I.soundManager.GetWoodSound();
                                    break;

                                case "Faith":

                                    break;

                                case "Stone":
                                    GameManager.I.soundManager.GetStoneSound();
                                    break;

                                default:
                                    break;
                                }

                                item.Value = 0;

                                if (cell.building.Population.Count > 0)
                                {
                                    GameManager.I.buildingManager.GetBuildingView(cell.building.UniqueID).SetBuildingStatus(BuildingState.Waiting);
                                }
                                else
                                {
                                    GameManager.I.buildingManager.GetBuildingView(cell.building.UniqueID).SetBuildingStatus(BuildingState.Waiting);
                                }
                            }
                        }
                        break;

                    case BuildingState.Destroyed:
                        GameManager.I.messagesManager.DesotryUiInformation(cell);
                        RemoveBuildingDebris(cell.building);
                        break;

                    case BuildingState.Waiting:
                        break;

                    default:
                        break;
                    }
                }
                else
                {
                    if (GameManager.I.gridController.CanUseMenu(this))
                    {
                        GameManager.I.soundManager.GetOpenMenuSound();
                        currentMenu = OpenMenuPlayerID();
                        if (currentMenu.PossibiliScelteAttuali.Count < 1)
                        {
                            currentMenu.Close();
                        }
                    }
                }
            }
            GameManager.I.uiManager.SetResourcesTextColor();
            GameManager.I.uiManager.SetFaithTextColor();
            if (_inputStatus.Start == ButtonState.Pressed)
            {
                GameManager.I.soundManager.GetOpenMenuSound();
                currentMenu    = OpenPauseMenu();
                Time.timeScale = 0.00000000001f;
                if (currentMenu.PossibiliScelteAttuali.Count < 1)
                {
                    currentMenu.Close();
                }
            }

            if (_inputStatus.RightShoulder == ButtonState.Pressed) // ADD POPULATION
            {
                if (GameManager.I.populationManager.GetAllFreePeople().Count > 0)
                {
                    BuildingData _building = GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid].building;
                    if (_building && _building.ID != "Casa" && _building.ID != "Muro" && _building.ID != "Torretta" && _building.CurrentState != BuildingState.Construction)
                    {
                        if (GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid].building.PopulationLimit > GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid].building.Population.Count)
                        {
                            List <PopulationData> freePeople = GameManager.I.populationManager.GetAllFreePeople();
                            int randomInd = Random.Range(0, freePeople.Count - 1);
                            AddPopulation(GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid].building, freePeople[randomInd].UniqueID);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }
            if (_inputStatus.LeftShoulder == ButtonState.Pressed) // Remove Population
            {
                if (GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid].building != null)
                {
                    BuildingData _building = GameManager.I.gridController.Cells[XpositionOnGrid, YpositionOnGrid].building;
                    if (_building.Population.Count > 0)
                    {
                        RemovePopulationFromBuilding(_building.Population[_building.Population.Count - 1].UniqueID, _building);
                        GameManager.I.messagesManager.ShowiInformation(MessageLableType.RemovePopulation, cell, true, "-1");
                    }
                }
                else
                {
                    return;
                }
            }
        }
        else
        {
            // Menu mode

            // controllo che la levetta sia stata rilasciata nei due sensi o quasi
            if (_inputStatus.LeftThumbSticksAxisY <= 0.2 && _inputStatus.LeftThumbSticksAxisY >= -0.2)
            {
                isReleasedVertical = true;
            }
            if (_inputStatus.LeftThumbSticksAxisX <= 0.2 && _inputStatus.LeftThumbSticksAxisX >= -0.2)
            {
                isReleasedHorizontal = true;
            }

            if ((_inputStatus.DPadUp == ButtonState.Pressed || _inputStatus.LeftThumbSticksAxisY >= 0.5) && isReleasedVertical) // GO UP
            {
                currentMenu.MoveToPrevItem();
                isReleasedVertical = false;
            }
            if ((_inputStatus.DPadLeft == ButtonState.Pressed || _inputStatus.LeftThumbSticksAxisX <= -0.5) && isReleasedHorizontal)// GO LEFT
            {
                isReleasedHorizontal = false;
            }
            if ((_inputStatus.DPadDown == ButtonState.Pressed || _inputStatus.LeftThumbSticksAxisY <= -0.5) && isReleasedVertical) // GO DOWN
            {
                currentMenu.MoveToNextItem();
                isReleasedVertical = false;
            }
            if ((_inputStatus.DPadRight == ButtonState.Pressed || _inputStatus.LeftThumbSticksAxisX >= 0.5) && isReleasedHorizontal) // GO RIGHT
            {
                isReleasedHorizontal = false;
            }
            if (_inputStatus.A == ButtonState.Pressed)// SELECT
            {
                GameManager.I.soundManager.GetOpenMenuSound();
                if (currentMenu.PossibiliScelteAttuali.Count > 0)
                {
                    currentMenu.AddSelection(currentMenu.PossibiliScelteAttuali[currentMenu.IndiceDellaSelezioneEvidenziata]);
                }
            }

            if (_inputStatus.B == ButtonState.Pressed)// DESELECT
            {
                GameManager.I.soundManager.BackMenuSound();
                currentMenu.GoBack();
            }
        }
    }
예제 #18
0
    public void SetupPlayers()
    {
        CellDoomstock hole = gridController.GetCellPositionByStatus(CellDoomstock.CellStatus.Hole);

        if (Players[0] != null)
        {
            Players[0].SetupInput(
                new PlayerInputData()
            {
                Up                = KeyCode.W,
                Left              = KeyCode.A,
                Down              = KeyCode.S,
                Right             = KeyCode.D,
                Confirm           = KeyCode.Z,
                AddPopulationUnit = KeyCode.X,
                GoBack            = KeyCode.E,
                PlayerPower       = KeyCode.Q,
                RemovePopulation  = KeyCode.C,
                Pause             = KeyCode.Escape,
                EndGame           = KeyCode.F1
            });

            Players[0].SetUpPosition((int)hole.GridPosition.x - 1, (int)hole.GridPosition.y - 1, CellSize);
        }

        if (Players[1] != null)
        {
            Players[1].SetupInput(
                new PlayerInputData()
            {
                Up                = KeyCode.I,
                Left              = KeyCode.J,
                Down              = KeyCode.K,
                Right             = KeyCode.L,
                Confirm           = KeyCode.N,
                AddPopulationUnit = KeyCode.U,
                GoBack            = KeyCode.O,
                PlayerPower       = KeyCode.P,
                RemovePopulation  = KeyCode.M,
                Pause             = KeyCode.F5,
                EndGame           = KeyCode.F2
            });

            Players[1].SetUpPosition((int)hole.GridPosition.x - 1, (int)hole.GridPosition.y + 1, CellSize);
        }

        if (Players[2] != null)
        {
            Players[2].SetupInput(
                new PlayerInputData()
            {
                Up                = KeyCode.UpArrow,
                Left              = KeyCode.LeftArrow,
                Down              = KeyCode.DownArrow,
                Right             = KeyCode.RightArrow,
                Confirm           = KeyCode.Home,
                AddPopulationUnit = KeyCode.PageUp,
                GoBack            = KeyCode.PageDown,
                PlayerPower       = KeyCode.Insert,
                RemovePopulation  = KeyCode.Keypad0,
                Pause             = KeyCode.Keypad0,
                EndGame           = KeyCode.F3
            });

            Players[2].SetUpPosition((int)hole.GridPosition.x + 1, (int)hole.GridPosition.y + 1, CellSize);
        }
        hole.SetStatus(CellDoomstock.CellStatus.Empty);
        #region Quarto player commento
        //if (Players[3] != null) {
        //    Players[3].SetupInput(
        //    new PlayerInputData() {
        //        Up = KeyCode.Keypad8,
        //        Left = KeyCode.Keypad4,
        //        Down = KeyCode.Keypad5,
        //        Right = KeyCode.Keypad6,
        //        Confirm = KeyCode.KeypadMultiply,
        //        PopulationMenu = KeyCode.KeypadPlus,
        //        GoBack = KeyCode.KeypadMinus,

        //    });

        //    Players[3].SetUpPosition((int)hole.GridPosition.x + 1, (int)hole.GridPosition.y - 1, CellSize);
        //}
        #endregion
    }
예제 #19
0
    /// <summary>
    /// aggiunge risorsa all'edificio cliccato
    /// </summary>
    /// <param name="building"></param>
    /// <param name="cell"></param>
    void AddResourceOnClick(BuildingData building, CellDoomstock cell)
    {
        switch (building.ID)
        {
        case "Cava":
            foreach (var res in building.BuildingResources)
            {
                res.Value += ProdModifiers.Cava;

                GameManager.I.messagesManager.ShowiInformation(MessageLableType.StoneProduction, cell, true, ProdModifiers.Cava.ToString());
            }
            break;

        case "Foresta":
            foreach (var res in building.BuildingResources)
            {
                res.Value += ProdModifiers.Foresta;
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.WoodProduction, cell, true, ProdModifiers.Foresta.ToString());
                GameManager.I.soundManager.AddWoodOnClickSound();
            }
            break;

        case "Fattoria":
            foreach (var res in building.BuildingResources)
            {
                res.Value += ProdModifiers.Fattoria;
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.FoodProduction, cell, true, ProdModifiers.Fattoria.ToString());
            }
            break;

        case "Chiesa":
            foreach (var res in building.BuildingResources)
            {
                res.Value += ProdModifiers.Chiesa;
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.FaithProduction, cell, true, ProdModifiers.Chiesa.ToString());
            }
            break;

        case "Torretta":
            foreach (var res in building.BuildingResources)
            {
                res.Value += ProdModifiers.Torretta;
            }
            break;

        case "Muro":
            foreach (var res in building.BuildingResources)
            {
                res.Value += ProdModifiers.Muro;
                //GameManager.I.buildingManager.GetBuildingView(building.UniqueID).BarrettaGrow += 0.5f;
            }

            break;

        case "Casa":
            foreach (var res in building.BuildingResources)
            {
                res.Value += ProdModifiers.Casa;
            }
            break;

        default:
            break;
        }
        if (cell.building.Population.Count == 0)
        {
            GameManager.I.buildingManager.GetBuildingView(building.UniqueID).AnimationStart(building);
            GameManager.I.buildingManager.GetBuildingView(building.UniqueID).AnimationStop(building);
        }
    }
예제 #20
0
    public void DoMoveStep(INode _step)
    {
        if (lastPos != null)
        {
            if (lastPos.Type != CellDoomstock.CellType.Forest)
            {
                if (lastPos.Status == CellDoomstock.CellStatus.Enemy)
                {
                    lastPos.SetStatus(CellDoomstock.CellStatus.Empty);
                    lastPos.EnemiesInCell.Remove(this);
                }
            }


            lastPos = CurrentPosition;
        }
        transform.DOLookAt(_step.GetWorldPosition(), MovementSpeed, AxisConstraint.Y);

        if (CurrentPath != null)
        {
            transform.DOMove((new Vector3(_step.GetWorldPosition().x, _step.GetWorldPosition().y - 0.8f, _step.GetWorldPosition().z + 0.4f)), MovementSpeed).OnComplete(() =>
            {
                CurrentNodeIndex++;
                int lastNode    = pathFindingSettings.MoveToLastButOne ? CurrentPath.Count - 2 : CurrentPath.Count - 1;
                CurrentPosition = _step as CellDoomstock;
                lastPos         = CurrentPosition;

                if (CurrentPosition.Type != CellDoomstock.CellType.Forest)
                {
                    if (CurrentPosition.Status != CellDoomstock.CellStatus.Debris)
                    {
                        if (CurrentPosition.Status != CellDoomstock.CellStatus.Filled)
                        {
                            CurrentPosition.SetStatus(CellDoomstock.CellStatus.Enemy);
                            CurrentPosition.EnemiesInCell.Add(this);
                        }
                    }
                }


                if (CurrentNodeIndex > lastNode)
                {
                    // ha raggiunto l'obbiettivo, attacca
                    if (Attack(CurrentTarget))
                    {
                        if (CurrentTarget.BuildingLife <= 0)
                        {
                            currentState = enemyState.Searching;
                            resetTarget();
                        }
                    }
                    //else
                    //    currentState = enemyState.Attack;
                }
                else
                {
                    AttackNextStep();
                    if (currentState == enemyState.MovingToTarget)
                    {
                        // prossimo step di movimento
                        this.DoMoveToCurrentPathStep();
                    }
                }
                if (OnStep != null)
                {
                    OnStep(this);
                }
            });
        }
    }
예제 #21
0
 void OnDataChanged(CellDoomstock _newData)
 {
     Init(_newData);
 }
예제 #22
0
    public IMenu ShowMenu(MenuTypes _type, Player _player)
    {
        FirstLevelSelectables.Clear();
        switch (_type)
        {
        case MenuTypes.Pause:
            FirstLevelSelectables.Add(
                new Selector()
            {
                UniqueID = "Resume", NameLable = "Resume"
            } as ISelectable);
            FirstLevelSelectables.Add(
                new Selector()
            {
                UniqueID = "Restart", NameLable = "Restart"
            } as ISelectable);
            FirstLevelSelectables.Add(
                new Selector()
            {
                UniqueID = "Back To Menu", NameLable = "Back To Menu"
            } as ISelectable);
            FirstLevelSelectables.Add(
                new Selector()
            {
                UniqueID = "Exit", NameLable = "Exit"
            } as ISelectable);
            FirstLevelSelectables.Add(
                new Selector()
            {
                UniqueID = "Credits", NameLable = "Credits"
            } as ISelectable);
            PauseMenu.Init(_player, FirstLevelSelectables);
            return(PauseMenu);

        case MenuTypes.EndGame:
            FirstLevelSelectables.Add(
                new Selector()
            {
                UniqueID = "Restart", NameLable = "Restart"
            } as ISelectable);
            FirstLevelSelectables.Add(
                new Selector()
            {
                UniqueID = "Back To Menu", NameLable = "Back To Menu"
            } as ISelectable);
            FirstLevelSelectables.Add(
                new Selector()
            {
                UniqueID = "Exit", NameLable = "Exit"
            } as ISelectable);
            FirstLevelSelectables.Add(
                new Selector()
            {
                UniqueID = "Credits", NameLable = "Credits"
            } as ISelectable);
            EndGameMenu.Init(_player, FirstLevelSelectables);
            return(EndGameMenu);

        case MenuTypes.Player:
            CellDoomstock cell = GameManager.I.gridController.Cells[_player.XpositionOnGrid, _player.YpositionOnGrid];
            switch (cell.Status)
            {
            case CellDoomstock.CellStatus.Empty:

                if (cell.Type != CellDoomstock.CellType.Forest)
                {
                    FirstLevelSelectables.Add(
                        new Selector()
                    {
                        UniqueID = " + Building", NameLable = "Add Building"
                    } as ISelectable);
                }
                break;

            case CellDoomstock.CellStatus.Hole:

                if (cell.Type != CellDoomstock.CellType.Forest)
                {
                    FirstLevelSelectables.Add(
                        new Selector()
                    {
                        UniqueID = " + Building", NameLable = "Add Building"
                    } as ISelectable);
                }
                break;

            case CellDoomstock.CellStatus.Filled:
                if (cell.building.PlayerOwner == _player)
                {
                    FirstLevelSelectables.Add(new Selector()
                    {
                        UniqueID = " - Building", NameLable = "Rem Building"
                    } as ISelectable);

                    if (cell.building.CurrentState == BuildingState.Ready)
                    {
                        FirstLevelSelectables.Add(new Selector()
                        {
                            UniqueID = " Prendi ", NameLable = " Prendi "
                        } as ISelectable);
                    }
                }
                else
                {
                    FirstLevelSelectables.Add(new Selector()
                    {
                        UniqueID = " Info ", NameLable = "Info"
                    } as ISelectable);
                }

                break;

            default:
                break;
            }
            switch (_player.ID)
            {
            case "Sindaco":
                P1_Menu.Init(_player, FirstLevelSelectables);
                return(P1_Menu);

            case "Esercito":
                P2_Menu.Init(_player, FirstLevelSelectables);
                return(P2_Menu);

            case "Clero":
                P3_Menu.Init(_player, FirstLevelSelectables);
                return(P3_Menu);

            default:
                break;
            }
            break;

        default:
            break;
        }
        return(null); // Menù not found
    }
예제 #23
0
    /// <summary>
    /// Chiamata ogni volta che viene settato lo status di un edificio.
    /// </summary>
    public void OnStatusChanged()
    {
        switch (Data.CurrentState)
        {
        case BuildingState.Construction:
            GameManager.I.soundManager.GetCostructionSound();
            CurrentMesh = GetComponent <MeshFilter>();
            if (Data.ID != "Meraviglia")
            {
                transform.DOMoveY(transform.position.y + 1, Data.BuildingTime).OnComplete(() => { SetBuildingStatus(BuildingState.Built); });
            }
            else
            {
                SetBuildingStatus(BuildingState.Built);
            }
            break;

        case BuildingState.Built:
            Data.Delay = 0;
            if (Data.Population.Count < 1)
            {
                AnimationStop(Data);
            }
            if (Data.ID == "Foresta")
            {
                CurrentMesh.mesh = Pino;
            }
            break;

        case BuildingState.Producing:
            AnimationStart(Data);
            if (Data.ID != "Foresta")
            {
                ;
            }
            break;

        case BuildingState.Ready:
            AnimationStop(Data);
            CellDoomstock cell = GameManager.I.gridController.Cells[(int)Data.GetGridPosition().x, (int)Data.GetGridPosition().y];
            switch (Data.ID)
            {
            case "Foresta":
                CurrentMesh.mesh = Pino;
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.LimitWood, cell);
                break;

            case "Cava":
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.LimitStone, cell);
                break;

            case "Chiesa":
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.LimitFaith, cell);
                break;

            case "Fattoria":
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.LimitFood, cell);
                break;

            case "Muro":
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.LimitSpirit, cell);
                break;

            case "Torretta":
                GameManager.I.messagesManager.ShowiInformation(MessageLableType.LimitSpirit, cell);
                break;

            default:
                break;
            }
            break;

        case BuildingState.Waiting:


            if (Data.ID == "Foresta")
            {
                CurrentMesh.mesh = Ceppo;
            }

            break;

        case BuildingState.Destroyed:
            CurrentMesh.mesh = Macerie;
            break;

        default:
            break;
        }
    }