Example #1
0
        private void RushCentral(Rusher_Controller_FSM rusher)
        {
            //modify the angle to rush outside
            float angle = Vector2.SignedAngle(rusher.Target.position - rusher.transform.position, new Vector2(1.0f, 0.0f));

            myRb.MoveRotation(Mathf.LerpAngle(myRb.rotation, -angle, rusher.rotationSpeed * Time.deltaTime));
        }
Example #2
0
        public override void Update(Rusher_Controller_FSM rusher)
        {
            //check if the defender is in the way
            if (rusher.RayToQb().collider == null)
            {
                //Debug.Log("Oliner out of sight");
                rusher.TransitionToState(rusher.qbChase_State);
            }

            Vector2 localRight = rusher.transform.rotation * Vector2.right;

            myRb.AddForce(localRight * rusher.speed * Time.deltaTime);

            /*if (rushMode == RushMode.Outside)
             * {
             *  RushOutside(rusher);
             * }*/
            switch (rushMode)
            {
            case RushMode.Central:
                RushCentral(rusher);
                //Debug.Log(rushMode);
                break;

            case RushMode.Inside:
                RushInside(rusher);
                //Debug.Log(rushMode);
                break;

            case RushMode.Outside:
                RushOutside(rusher);
                //Debug.Log(rushMode);
                break;
            }
        }
Example #3
0
 public override void EnterState(Rusher_Controller_FSM rusher)
 {
     myRb = rusher.myRb;
     //Decide if you want to go inside or outside
     //for now go outside
     rushMode = getRandomRushmode();
 }
Example #4
0
        private void RushInside(Rusher_Controller_FSM rusher)
        {
            //get the world coord of the point which is 1 left localy from the defender
            Vector2 leftToTarget = rusher.Target.TransformPoint(Vector3.up * .5f);

            //modify the angle to rush outside
            float angle = Vector2.SignedAngle(leftToTarget - (Vector2)rusher.transform.position, new Vector2(1.0f, 0.0f));

            myRb.MoveRotation(Mathf.LerpAngle(myRb.rotation, -angle, rusher.rotationSpeed * Time.deltaTime));
        }
Example #5
0
        public override void OnCollisionEnter(Rusher_Controller_FSM rusher, Collider2D col)
        {
            //if(other.gameObject.tag == "Defender" && !opponents.Contains(other.gameObject))
            if (col.gameObject.tag == "Defender")
            {
                rusher.Target   = col.transform;
                rusher.defender = col.GetComponent <DefenderController_FSM>();

                //rusher.TransitionToState(rusher.oppVisible_State);
            }
        }
Example #6
0
        public override void Update(Rusher_Controller_FSM rusher)
        {
            RaycastHit2D hit = rusher.RayToQb();

            //check if the defender is in the way
            if (hit.collider != null)
            {
                rusher.Target = hit.transform;

                rusher.TransitionToState(rusher.oppVisible_State);
                //Debug.Log("Oliner in sight");
            }

            Vector2 localRight = rusher.transform.rotation * Vector2.right;

            myRb.AddForce(localRight * rusher.speed * Time.deltaTime);

            float angle = Vector2.SignedAngle(rusher.Target.position - rusher.transform.position, new Vector2(1.0f, 0.0f));

            myRb.MoveRotation(Mathf.LerpAngle(myRb.rotation, -angle, rusher.rotationSpeed * Time.deltaTime));
        }
Example #7
0
        public override void EnterState(Rusher_Controller_FSM rusher)
        {
            myRb = rusher.myRb;

            rusher.Target = rusher.Qb;
        }
Example #8
0
 public override void CleanUp(Rusher_Controller_FSM rusher)
 {
 }
Example #9
0
 public override void OnCollisionEnter(Rusher_Controller_FSM rusher, Collider2D col)
 {
 }
Example #10
0
 public abstract void Update(Rusher_Controller_FSM rusher);
Example #11
0
 public abstract void EnterState(Rusher_Controller_FSM rusher);
Example #12
0
 public abstract void CleanUp(Rusher_Controller_FSM rusher);
Example #13
0
 public abstract void OnCollisionEnter(Rusher_Controller_FSM rusher, Collider2D col);