예제 #1
0
    public override void AICalculate()
    {
        float distanceSqr = Vector2.SqrMagnitude((Vector2)PositionConvertor.GetWorldPositionFromActorTileIndex
                                                     (this.m_TargetPosition) - (Vector2)this.m_AIBehavior.transform.position);

        if (this.m_Target == null)
        {
            InvaderIdleState idleState = new InvaderIdleState(this.m_AIBehavior, false);
            this.m_AIBehavior.ChangeState(idleState);
        }
        else
        {
            if (distanceSqr <= this.CharacterAI.AttackBehavior.AttackScopeSqr)
            {
                BuildingBasePropertyBehavior property = this.m_Target.GetComponent <BuildingBasePropertyBehavior>();
                AttackState attackState;
                if (property == null)
                {
                    attackState = new InvaderAttackState(this.m_AIBehavior, new AITargetObject(this.m_Target, this.m_Target.transform.position), this.CharacterAI.AttackBehavior);
                }
                else
                {
                    attackState = new InvaderAttackState(this.m_AIBehavior,
                                                         new AITargetObject(this.m_Target, (Vector2)(PositionConvertor.GetWorldPositionFromActorTileIndex(this.m_TargetPosition))), this.CharacterAI.AttackBehavior);
                }
                this.m_AIBehavior.ChangeState(attackState);
            }
            else
            {
                base.AICalculate();
            }
        }
    }
예제 #2
0
    protected override void OnTargetReached()
    {
        InvaderIdleState idleState = new InvaderIdleState(this.m_AIBehavior, false);

        this.m_AIBehavior.ChangeState(idleState);
    }
예제 #3
0
    public virtual void SetIdle(bool isResponseInstantly)
    {
        InvaderIdleState idleState = new InvaderIdleState(this, isResponseInstantly);

        this.ChangeState(idleState);
    }