コード例 #1
0
ファイル: AgentState.cs プロジェクト: emreedemir/TPC
        public override void Update()
        {
            if (base.agentPlayer.IsTarget())
            {
                if (base.agentPlayer.IsTargetFarAway())
                {
                    //KOŞ YANINA
                }
                else if (base.agentPlayer.IsTargetNear())
                {
                    //Eger  düşman saldırıyorsa
                    if (base.agentPlayer.ShouldDefence())
                    {
                        nextAgentState = new DefenceAgent(base.agentTransform, base.navMeshagent, base.animationController);
                    }
                }
                else if (base.agentPlayer.IsTargetTooNear())
                {
                    //
                    //
                }
                if (!base.agentPlayer.ShouldDefence())
                {
                    nextAgentState = new IdleAgent(base.agentTransform, base.navMeshagent, base.animationController);

                    Exit();
                }
                else if (!InSecure())
                {
                    if (rolled == true)
                    {
                        rollingTime += Time.deltaTime;
                    }
                    if (rollingTime > 2 || rolled == false)
                    {
                        if (base.agentPlayer.GetDistanceFromAgentToTarget() < 2)
                        {
                            animationController.RollTrigger();

                            animationController.LeftAxis(0, -1);

                            rollingTime = 0;

                            rolled = true;
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: AgentState.cs プロジェクト: emreedemir/TPC
        public override void Update()
        {
            if (base.agentPlayer.IsTarget())
            {
                if (base.agentPlayer.AttackMode())
                {
                    if (base.agentPlayer.IsTargetFarAway())
                    {
                        //KOŞ YANINA

                        ResetTurnAxis();

                        nextAgentState = new RunAgent(base.agentTransform, base.navMeshagent, base.animationController);

                        Exit();
                    }
                    else if (base.agentPlayer.IsTargetNear())
                    {
                        if (base.agentPlayer.IsLookAtTarget())
                        {
                            ResetTurnAxis();

                            if (base.agentPlayer.ShouldDefence())
                            {
                                nextAgentState = new DefenceAgent(base.agentTransform, base.navMeshagent, base.animationController);

                                Exit();
                            }
                            else if (base.agentPlayer.ShouldAttack())
                            {
                                nextAgentState = new AgentAttackL(base.agentTransform, base.navMeshagent, base.animationController);

                                Exit();
                            }
                        }
                        else
                        {
                            float angle = base.agentPlayer.GetAngleBetweenFromAgentToTarget();

                            if (angle > 0)
                            {
                                animationController.TurnAxis(-angle * Time.deltaTime * 10, 0);
                            }
                            else
                            {
                                animationController.TurnAxis(angle * Time.deltaTime * 10, 0);
                            }
                        }
                    }
                    else if (base.agentPlayer.IsTargetTooNear())
                    {
                        if (!base.agentPlayer.IsLookAtTarget())
                        {
                            float angle = base.agentPlayer.GetAngleBetweenFromAgentToTarget();

                            if (angle > 0)
                            {
                                animationController.TurnAxis(-angle * Time.deltaTime * 10, 0);
                            }
                            else
                            {
                                animationController.TurnAxis(angle * Time.deltaTime * 10, 0);
                            }
                        }
                        else if (base.agentPlayer.ShouldAttack())
                        {
                            ResetTurnAxis();
                            nextAgentState = new AgentAttackL(base.agentTransform, base.navMeshagent, base.animationController);

                            Exit();
                        }
                        else if (base.agentPlayer.ShouldDefence())
                        {
                            ResetTurnAxis();
                            nextAgentState = new DefenceAgent(base.agentTransform, base.navMeshagent, base.animationController);

                            Exit();
                        }
                    }
                }
            }
        }