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));
    }
 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();
 }
    public override void Update(Rusher_Controller_FSM rusher)
    {
        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));
    }
    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));
    }
    public override void Update(Rusher_Controller_FSM rusher)
    {
        Vector2 localRight = rusher.transform.rotation * Vector2.right;

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

        if (rushMode == RushMode.Outside)
        {
            RushOutside(rusher);
        }
    }
    //public List<GameObject> opponents = new List<GameObject>();

    private void OnTriggerEnter2D(Collider2D other)
    {
        //if(other.gameObject.tag == "Defender" && !opponents.Contains(other.gameObject))
        if (other.gameObject.tag == "Defender")
        {
            Rusher_Controller_FSM rush_Controller = transform.parent.GetComponent <Rusher_Controller_FSM>();
            rush_Controller.Target = other.transform;

            rush_Controller.TransitionToState(rush_Controller.oppVisible_State);
        }
    }
예제 #7
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);
        }
    }
 public override void CleanUp(Rusher_Controller_FSM rusher)
 {
 }
 public override void OnCollisionEnter(Rusher_Controller_FSM rusher, Collider2D col)
 {
 }
 public override void EnterState(Rusher_Controller_FSM rusher)
 {
     myRb          = rusher.myRb;
     rusher.Target = rusher.Qb;
 }
 public abstract void OnCollisionEnter(Rusher_Controller_FSM rusher, Collider2D col);
 public abstract void Update(Rusher_Controller_FSM rusher);
 public abstract void EnterState(Rusher_Controller_FSM rusher);
 public abstract void CleanUp(Rusher_Controller_FSM rusher);