コード例 #1
0
ファイル: PushState.cs プロジェクト: KangLLL/century_war
    public override void AICalculate()
    {
        CharacterAI characterAI = (CharacterAI)this.m_AIBehavior;

        if (this.m_Ticks++ == this.m_PushTicks)
        {
            characterAI.SetIdle(false);
        }
        else
        {
            this.m_PushVelocity *= this.m_PushAttenuateFactor;
            Vector2 v           = this.m_PushVelocity * this.m_PushFactor;
            Vector2 newPosition = (Vector2)this.m_AIBehavior.transform.position + v;

            newPosition = PositionConvertor.ClampWorldPositionOfActorTile(newPosition);
            TilePosition currentTile = PositionConvertor.GetActorTileIndexFromWorldPosition(this.m_AIBehavior.transform.position);
            TilePosition newTile     = PositionConvertor.GetActorTileIndexFromWorldPosition(new Vector3(newPosition.x, newPosition.y));
            if (BattleMapData.Instance.ActorCanPass(newTile.Row, newTile.Column) && BattleMapData.Instance.ActorCanPass(currentTile.Row, currentTile.Column))
            {
                this.m_AIBehavior.transform.position = new Vector3(newPosition.x, newPosition.y, this.m_AIBehavior.transform.position.z);
                if (newTile != this.m_PreviousPosition)
                {
                    BattleMapData.Instance.RefreshInformationWithMoveActor(this.m_AIBehavior.gameObject, this.m_PreviousPosition, newTile);
                    this.m_PreviousPosition = newTile;
                    if (characterAI.BattleMapData.ActorCanPass(newTile.Row, newTile.Column))
                    {
                        characterAI.PreviousValidPosition = newTile;
                    }
                }
            }
        }
    }