コード例 #1
0
ファイル: AIPilot.cs プロジェクト: alexander-t/swss
        void Update()
        {
            try
            {
                Direction availableDirections = pathFinding.FirstPassRaycast();
                if (availableDirections == Direction.None)
                {
                    Debug.Log("STUCK! Cheating!");
                    transform.Rotate(0, 180, 0);
                }
                else
                {
                    // Do collision detection; if nothing is blocking, let the behavior decide the movement
                    Vector3 turningDirection = pathFinding.DetermineTurningDirection(availableDirections);
                    if (turningDirection != Vector3.zero)
                    {
                        transform.Rotate(turningDirection * ship.AngularVelocity * Time.deltaTime);
                    }
                    else
                    {
                        behavior.Turn();
                    }
                    Move();
                }
                behavior.Attack();
            }
            catch (BehaviorNotApplicableException e)
            {
                if (e.Reason == BehaviorChangeReason.TargetAcquired)
                {
                    Attack(e.Target);
                }
                else
                {
                    behavior = DetermineDefaultBehavior();
                    behavior.Commence();

                    // Forget whoever fired at this ship
                    enemyToRetaliateAgainst = null;
                }
            }
            Debug.Log(behavior.Describe());
        }
コード例 #2
0
ファイル: AIPilot.cs プロジェクト: alexander-t/swss
 public void Attack(GameObject target)
 {
     behavior = new AttackingBehavior(gameObject, rightGunTransform, leftGunTransform, target);
     behavior.Commence();
 }
コード例 #3
0
ファイル: AIPilot.cs プロジェクト: alexander-t/swss
 void Start()
 {
     pathFinding = new PathFinding(transform);
     behavior    = DetermineDefaultBehavior();
     behavior.Commence();
 }