Exemplo n.º 1
0
    public void Setup(Hero _hero, e_teams _team, int _index, Vector2Int _position, HeroUI _heroUI)
    {
        _transform.position = new Vector3(_transform.position.x, _transform.position.y, -1);
        hero     = _hero;
        team     = _team;
        index    = _index;
        position = _position;
        ui       = _heroUI;
        Color color = _team == e_teams.Blue ? GameplayManager.Instance.Data.Colors[2] : GameplayManager.Instance.Data.Colors[3];

        ui.Setup(this, color);
        visual.sprite = hero.Graph;

        stats.Add(e_stats.Health, new Stat(e_stats.Health, hero.Health));
        stats.Add(e_stats.Speed, new Stat(e_stats.Speed, hero.Speed));
        stats.Add(e_stats.Damage, new Stat(e_stats.Damage, hero.Damage));
        stats.Add(e_stats.Range, new Stat(e_stats.Range, hero.Range));
        stats.Add(e_stats.Critic, new Stat(e_stats.Critic, hero.Critic));

        hero.Attack.Set();
        hero.Active.Set();
        hero.Passive.Set();

        UpdateUI();
    }
Exemplo n.º 2
0
    public void Setup(Vector2Int _position, e_squareType _type, e_teams _team)
    {
        position   = _position;
        squareType = _type;
        team       = _team;

        Colorisation();
    }
Exemplo n.º 3
0
    public void Init(OnlineManager _onlineManager, e_teams _team, int[] _heroes)
    {
        team          = _team;
        onlineManager = _onlineManager;
        utility       = new BoardUtility(map.Board, map.MapSize);

        inputManager.GameStart(team);
        boardManager.GameStart(_heroes);
        deckManager.GameStart();

        ChangeStep(e_step.Placement);
    }
Exemplo n.º 4
0
 public void Eliminated(e_teams _team)
 {
     if (_team == team)
     {
         eliminated = true;
         uiManager.GameEnd(false);
     }
     else
     {
         Debug.Log("le joueur " + _team + " a perdu");
     }
 }
Exemplo n.º 5
0
    public void StartSelection(e_teams _team)
    {
        playPannel.SetActive(false);
        teamText.text  = _team.ToString() + " Team";
        teamText.color = datas.Colors[(int)_team + 1];
        selectionPannel.SetActive(true);

        for (int i = 0; i < datas.Heroes.Length; i++)
        {
            GameObject instance = Instantiate(tokkenPrefab, grid);
            instance.GetComponent <HeroeTokken>().Init(datas, i);
        }
    }
Exemplo n.º 6
0
    public void GenerateMap()
    {
        foreach (Square s in squaresList)
        {
            DestroyImmediate(s.gameObject);
        }

        squaresList.Clear();

        if (map != null)
        {
            mapSize = map.MapSize;
        }
        int current = 0;

        float spriteSize = squarePrefab.GetComponentInChildren <SpriteRenderer>().sprite.bounds.size.x / 2;

        Vector2 mapSpace = new Vector2(sideSpace - spriteSize, sideSpace - spriteSize);

        float step = mapSpace.x * 2 / (mapSize.x - 1);

        startingPoint = new Vector2(-mapSpace.x, step / 2 * (mapSize.y - 1));


        for (int i = 0; i < mapSize.x; i++)
        {
            for (int j = 0; j < mapSize.y; j++)
            {
                GameObject inst = Instantiate(squarePrefab, transform);
                inst.transform.localPosition = new Vector2(startingPoint.x + step * i, startingPoint.y - step * j);

                Square square = inst.GetComponent <Square>();

                e_squareType type = map != null ? map.SquaresList[current].Type : (e_squareType)Random.Range(1, (int)e_squareType.Obstacle + 1);
                e_teams      team = map != null ? map.SquaresList[current].Team : e_teams.Default;

                square.Setup(new Vector2Int(i, j), type, team);
                current++;

                squaresList.Add(square);
            }
        }
    }
Exemplo n.º 7
0
    private void CreateHeroPiece(int _heroIndex, e_teams _team, Vector2Int _position)
    {
        Square     start    = board[_position.x, _position.y];
        GameObject instance = Instantiate(heroePiecePrefab, start.transform.position, Quaternion.identity, null);
        HeroUI     ui       = gameplayManager.UIManager.CreateHeroUI();
        HeroPiece  piece    = instance.GetComponent <HeroPiece>();

        piece.Setup(gameplayManager.Data.Heroes[_heroIndex], _team, pieces.Count, _position, ui);
        start.ChangeOccupied(instance.GetComponent <HeroPiece>());

        if (gameplayManager.Team == _team)
        {
            gameplayManager.OnYourTurn += piece.TurnDebute;
        }
        else
        {
            gameplayManager.OnEnnemyTurn += piece.TurnDebute;
        }

        pieces.Add(piece);
    }
Exemplo n.º 8
0
 public void GameStart(e_teams _team)
 {
     team = _team;
 }
Exemplo n.º 9
0
    //Loop
    void FixedUpdate()
    {
        foreach (Message m in messages)
        {
            #region Join/Left Room
            if (m.Type == "PlayerJoined")
            {
                if (!teamAttributed)
                {
                    team           = (e_teams)m.GetInt(0);
                    teamAttributed = true;
                }
                if (m.GetInt(0) == 2)
                {
                    if (currentStatus == e_status.Default)
                    {
                        GetComponent <SelectionInputs>().StartSelection(team);
                        currentStatus = e_status.InSelection;
                    }
                }
            }

            else if (m.Type == "PlayerLeft")
            {
                if (currentStatus == e_status.InSelection)
                {
                    DisconnectMe();
                }
                else if (currentStatus == e_status.InGame)
                {
                    gameplayManager.GameEnd();
                    currentStatus = e_status.GameEnded;
                }
            }

            else if (m.Type == "FullRoom")
            {
                ListRoomsJoin(roomInfos.ToArray());
            }
            #endregion

            #region Initialization Checks
            else if (m.Type == "TeamValidated")
            {
                for (int i = 0; i < 6; i++)
                {
                    heroes[i] = m.GetInt((uint)i);
                }

                SceneTransi.ToExecute exe = LoadGameplay;
                SceneTransi.Instance.Transi(true, exe);
            }

            else if (m.Type == "SceneLoaded")
            {
                gameplayManager = FindObjectOfType <GameplayManager>();

                gameplayManager.Init(this, team, heroes);
                gameplayManager.OnEnnemyTurn += EnnemyTurn;

                SceneTransi.Instance.Transi(false, null);

                Destroy(GetComponent <SelectionInputs>());
                currentStatus = e_status.InGame;
            }

            else if (m.Type == "PlacementValidated")
            {
                gameplayManager.BoardManager.PlacementValidated();
            }

            else if (m.Type == "GameStart")
            {
                gameplayManager.GameStart();
            }
            #endregion

            #region In Game
            else if (m.Type == "MoveHeroPiece")
            {
                int index = -1;
                index = m.GetInt(0);
                Vector2Int desti   = new Vector2Int(m.GetInt(1), m.GetInt(2));
                bool       useMove = m.GetBoolean(3);

                gameplayManager.BoardManager.MoveHeroPiece(index, desti, useMove);
            }

            else if (m.Type == "ModifyStatHeroPiece")
            {
                int index = -1;
                index = m.GetInt(0);
                e_stats key      = (e_stats)m.GetInt(1);
                int     value    = m.GetInt(2);
                int     duration = m.GetInt(3);
                int     tick     = m.GetInt(4);

                gameplayManager.BoardManager.ModifyStatHeroPiece(index, key, value, duration, tick);
            }

            else if (m.Type == "YourTurn")
            {
                gameplayManager.YourTurn();
            }

            else if (m.Type == "Eliminated")
            {
                gameplayManager.Eliminated((e_teams)m.GetInt(0));

                if (m.GetInt(1) <= 1)
                {
                    gameplayManager.GameEnd();
                    currentStatus = e_status.GameEnded;
                }
            }
            #endregion
        }

        messages.Clear();
    }