コード例 #1
0
    void moveTowardsPlayer()
    {
        if (Vector3.Distance(player.transform.position, transform.position) < attackRange)
        {
            enemyAction = attackPlayer;
        }

        float playerMoveSpeed = player.GetComponent <BoatController> ().getCurrentMoveSpeed();
        // move towards some point in front of the player
        Vector3 targetPosition = player.transform.position + player.transform.forward * playerMoveSpeed;

        //Debug.Log (targetPosition);

        boat.steerToVector(targetPosition - transform.position);
        //transform.rotation = Quaternion.LookRotation(Vector3.RotateTowards (transform.forward, targetPosition, 5, 0));

        // am I pointed towards that point?
        // forward is where the boat is facing
        // target - trans is the line from me to the target
        // these should be the same

        /*
         * float dot = Vector3.Angle ((targetPosition - transform.position).normalized, transform.forward);
         * Debug.Log ("Angle: " + dot + " forward: "+transform.forward + " line: "+ (targetPosition - transform.position).normalized);
         * boat.steer(dot / Mathf.Abs(dot));
         * // Vector3.Distance(player.transform.position, transform.position)
         *
         *
         * Vector3 lineToPlayer = (player.transform.position - transform.position).normalized;
         *
         * boat.adjustThrottle (lineToPlayer.z);
         * boat.steer (lineToPlayer.x);
         */
    }
コード例 #2
0
 void stopMoving()
 {
     // slow the boat down until it stops
     boat.adjustThrottle(-1.0f);
     if (boat.getCurrentMoveSpeed() < 0.1f)
     {
         enemyAction = sink;
     }
 }
コード例 #3
0
 void die()
 {
     // death
     // health component ran out of health so it called this
     enemyAction = stopMoving;
     if (Random.Range(0, 4) == 0)
     {
         dropCrew();
     }
 }
コード例 #4
0
 void attackPlayer()
 {
     if (Vector3.Distance(player.transform.position, transform.position) > attackRange)
     {
         enemyAction = moveTowardsPlayer;
     }
     else if (boat.canShoot())
     {
         boat.Shoot(calculateAimPosition());
     }
 }
コード例 #5
0
 // Use this for initialization
 void Start()
 {
     if (player == null)
     {
         player = FindObjectOfType <CharacterController> ().gameObject;
     }
     boat        = GetComponent <BoatController> ();
     enemyAction = attackPlayer;
     boat.adjustThrottle(1);
     GetComponent <Health> ().OnDeath += die;
 }
コード例 #6
0
ファイル: Engine.cs プロジェクト: littlefluffie/NaGaDeMo
 public Opponent(DecisionDelegate AI)
 {
     Engine.OpponentTurnStart += Engine_OpponentTurnStart;
     Engine.OpponentTurnEnd += Engine_OpponentTurnEnd;
     MakeDecision = AI;
 }
コード例 #7
0
 public void dieFromReset()
 {
     // called when the player dies
     enemyAction = stopMoving;
 }
コード例 #8
0
    public DecisionNode(DecisionDelegate decision, AI ai)
    {
        decisionDelegate = decision;

        aiAgent = ai;
    }