Exemplo n.º 1
0
    private void Encounter()
    {
        // this state has perpose for wait all animation finish after user select path.
        // TODO wait for animation finish.

        if (m_currentPlayer.Poring.Target != null)
        {
            m_currentPlayer.Poring.Behavior.AttackTarget();
        }
        else
        {
            #region uncomment this when unpause feture monster
            // Node node = m_currentPlayer.Poring.Node;
            // if(node.TileProperty.Type != TileType.Sanctuary && node.monsters.Count < 1)
            // {
            //     var baseMonster = m_monsterPool.GetMonster(Turn);
            //     Debug.LogError(baseMonster.name);
            //     if(baseMonster)
            //     {
            //         GameObject obj = Instantiate(baseMonster.Prefab);
            //         BaseMonster monster = obj.GetComponent<BaseMonster>();
            //         monster.Init(baseMonster, m_currentPlayer.Poring);
            //         m_currentPlayer.Poring.Behavior.AttackMonster(monster);
            //     }
            // }
            // else
            #endregion
            CurrentGameState = eStateGameMode.EndTurn;
        }
    }
Exemplo n.º 2
0
    private IEnumerator CheckEndRoundCondition()
    {
        StartCoroutine(m_currentPlayer.Poring.OnEndTurn());
        yield return(new WaitForSeconds(1));

        m_poringGetUltimate.Clear();
        if ((m_currentPlayer.Index + 1) >= m_player.Count)
        {
            m_currentPlayer.Index = IndexCurrentPlayer = 0;
            RespawnValueOnTile(false);
            yield return(new WaitForSeconds(1));
        }
        else
        {
            m_currentPlayer.Index += 1;
            IndexCurrentPlayer     = m_currentPlayer.Index;
        }

        if (m_currentPlayer.Index == 0)
        {
            Turn++;
        }


        SetCurrentPlayer(m_player[m_currentPlayer.Index]);
        CurrentGameState = eStateGameMode.StartTurn;
    }
Exemplo n.º 3
0
 private void EndGame()
 {
     // Debug.LogError("EndGame");
     StopCoroutine("UpdateState");
     CurrentGameState = eStateGameMode.EndGame;
     // StopAllCoroutines();
     HUDController.Instance.ShowTextEndGame();
     TurnActiveUIController.Instance.NotMyTurn();
 }
Exemplo n.º 4
0
    private void StartTurn()
    {
        if (m_currentPlayer.Poring == null)
        {
            return;
        }

        m_cameraController.SetTarget(m_currentPlayer.Poring);
        m_cameraController.Show(CameraType.Default);
        StartCoroutine(m_currentPlayer.Poring.OnStartTurn());
        //TODO enable UI Roll/another action.
        CurrentGameState = eStateGameMode.ActiveTurn;
    }
Exemplo n.º 5
0
    private void ReceiveNodeAttackTarget(Node node, int attackA, int attackB, int defendA, int defendB)
    {
        List <Poring> porings = node.porings.FindAll(poring => poring != m_currentPlayer.Poring);

        m_currentPlayer.Poring.Target = porings[Random.Range(0, porings.Count - 1)];

        m_currentPlayer.Poring.AttackResultIndex = attackA;
        m_currentPlayer.Poring.DefendResultIndex = defendA;

        m_currentPlayer.Poring.Target.AttackResultIndex = attackB;
        m_currentPlayer.Poring.Target.DefendResultIndex = defendB;

        m_cameraController.Show(CameraType.Action);

        ResetNodeColor();
        CurrentGameState = eStateGameMode.Encounter;
    }
Exemplo n.º 6
0
    public override void OnActivate(Poring poring, Poring targetPoring = null, Node targetNode = null, List <Node> nodeList = null)
    {
        gameMode = (PrototypeGameMode)PrototypeGameMode.Instance;

        if (targetPoring != null || targetNode != null)
        {
            GameObject target = (targetPoring != null) ? targetPoring.gameObject : targetNode.gameObject;
            poring.transform.LookAt(target.transform.position);
        }

        CurrentCD = TurnCD;
        targetOnRoute.Clear();

        if (nodeList != null)
        {
            // Move first!!
            nextState = eStateGameMode.EndTurn;
            if (IsAppendDamageOnRoute)
            {
                nodeList.ForEach(n =>
                {
                    n.porings.ForEach(p =>
                    {
                        if (p != targetPoring || p != poring)
                        {
                            targetOnRoute.Add(p);
                        }
                    });
                });
            }

            poring.Behavior.SetupJumpToNodeTarget(nodeList, () => SkillEffectActivate(poring, targetPoring, targetNode));
        }
        else
        {
            nextState = (poring.Property.UltimateSkill.name == name) ? eStateGameMode.EndTurn : gameMode.CurrentGameState;
            SkillEffectActivate(poring, targetPoring, targetNode);
        }
    }
Exemplo n.º 7
0
    public IEnumerator UpdateState()
    {
        yield return(new WaitForSeconds(2));

        while (PrevGameState != eStateGameMode.EndGame)
        {
            yield return(new WaitForEndOfFrame());

            if (PrevGameState != CurrentGameState)
            {
                PrevGameState = CurrentGameState;
                switch (CurrentGameState)
                {
                case eStateGameMode.StartTurn:
                    StartTurn();
                    break;

                case eStateGameMode.ActiveTurn:
                    ActiveTurn();
                    break;

                case eStateGameMode.Encounter:
                    Encounter();
                    break;

                case eStateGameMode.EndTurn:
                    EndTurn();
                    break;

                case eStateGameMode.EndGame:
                    EndGame();
                    break;
                }
            }
        }
    }
Exemplo n.º 8
0
    private void ReceiveNodeSelected(Node node, int attackA, int attackB, int defendA, int defendB)
    {
        if (node)
        {
            // Debug.Log("You selected the " + node.nid);
            // SFX.PlayClip(resource.sound[0]).GetComponent<AudioSource>().time = 0.3f;
            node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected));
            MagicCursor.Instance.MoveTo(node);
            if (node == m_currentPlayer.Poring.Node && CheckAnotherPoringInTargetNode(node) && node.TileProperty.Type != TileType.Sanctuary)
            {
                List <Poring> porings = node.porings.FindAll(poring => poring != m_currentPlayer.Poring);
                m_currentPlayer.Poring.Target = porings[Random.Range(0, porings.Count - 1)];

                m_currentPlayer.Poring.AttackResultIndex = attackA;
                m_currentPlayer.Poring.DefendResultIndex = defendA;

                m_currentPlayer.Poring.Target.AttackResultIndex = attackB;
                m_currentPlayer.Poring.Target.DefendResultIndex = defendB;

                m_cameraController.Show(CameraType.Action);
                isSelectedNode = true;
                ResetNodeColor();
                CurrentGameState = eStateGameMode.Encounter;
            }
            else if (node.steps.Count > 0 && (CheckAnotherPoringInTargetNode(node) || node.steps.Find(step => step == m_step) == m_step))
            {
                MagicCursor.Instance.MoveTo(node);

                if (CheckAnotherPoringInTargetNode(node) && node.TileProperty.Type != TileType.Sanctuary)
                {
                    List <Poring> porings = node.porings.FindAll(poring => poring != m_currentPlayer.Poring);
                    m_currentPlayer.Poring.Target = porings[Random.Range(0, porings.Count - 1)];

                    m_currentPlayer.Poring.AttackResultIndex = attackA;
                    m_currentPlayer.Poring.DefendResultIndex = defendA;

                    m_currentPlayer.Poring.Target.AttackResultIndex = attackB;
                    m_currentPlayer.Poring.Target.DefendResultIndex = defendB;

                    RouteList.Clear();
                    FindRouteNode(m_step, 0, m_currentPlayer.Poring.Node, m_currentPlayer.Poring.PrevNode);

                    RouteList = FindTargetRoute(RouteList, node);
                }
                else if (node.steps.Find(step => step == m_step) == m_step)
                {
                    m_currentPlayer.Poring.Target = null;

                    RouteList.Clear();
                    RouteToNode(node);
                }

                int indexRoute = Random.Range(0, RouteList.Count - 1);

                // TODO send result route to rendar path with UI
                m_currentPlayer.Poring.Behavior.SetupJumpToNodeTarget(RouteList[indexRoute]);

                m_cameraController.Show(CameraType.Action);
                isSelectedNode = true;
                ResetNodeColor();
            }
        }
    }
Exemplo n.º 9
0
    private void OnEvent(EventData photonEvent)
    {
        object[] data = (object[])photonEvent.CustomData;
        switch (photonEvent.Code)
        {
        // Move
        case (byte)EventCode.BeginRollMove:
            BeginRollMove((int)data[0], (int)data[1]);
            break;

        case (byte)EventCode.SelectNodeMove:
            ReceiveNodeSelected(GetNodeByNodeId((int)data[0]), (int)data[1], (int)data[2], (int)data[3], (int)data[4]);
            break;

        // Attack
        case (byte)EventCode.SelectNodeAttack:
            Node node = GetNodeByNodeId((int)data[0]);
            if (!IsMineTurn())
            {
                node.PointRenderer.SetPropertyBlock(MaterialPreset.GetMaterialPreset(EMaterialPreset.selected));
                MagicCursor.Instance.MoveTo(node);
            }
            ReceiveNodeAttackTarget(node, (int)data[1], (int)data[2], (int)data[3], (int)data[4]);
            break;

        case (byte)EventCode.HighlightNodeAttack:
            CheckHasTargetInRange((int)data[0]);
            DisplayNodeHeatByAttackRange();
            if (IsMineTurn())
            {
                StartCoroutine(WaitForSelectTarget());
            }
            break;

        // Use skill
        case (byte)EventCode.SelectNodeSkill:
            ReceiveNodeSkillSelected(GetNodeByNodeId((int)data[0]), GetSkillOfPoring((string)data[1], (int)data[2]));
            break;

        case (byte)EventCode.HighlightNodeSkill:
            BaseSkill skill = GetSkillOfPoring((string)data[0], (int)data[1]);
            ParseSelectableNode(skill);
            DisplayNodeHeatBySkill(skill);
            if (IsMineTurn())
            {
                StartCoroutine(WaitForSelectTarget(skill));
            }
            break;

        // Roll end
        case (byte)EventCode.RollEnd:
            Poring poring = m_player[(int)data[2]];
            OnRollEnd((int)data[0], (DiceType)((int)data[1]), poring);
            break;

        // On click cancel
        case (byte)EventCode.OnClickCancel:
            ResetNodeColor();
            break;

        case (byte)EventCode.SkipToEndTurn:
            CameraController.Instance.Show(CameraType.Default);
            CurrentGameState = eStateGameMode.EndTurn;
            break;
        }
    }