Example #1
0
        public override void EnterState(DefenderController_FSM player)
        {
            //on reset the joint should be disabled
            player.joint.enabled = false;

            frameCounter = 20;
        }
        public override void EnterState(DefenderController_FSM player)
        {
            //player.StartCoroutine(DuellRotateTest_Cor(player));

            //this is for preventing the angular velocity problem
            player.myRb.isKinematic        = true;
            player.myRb.angularVelocity    = 0.0f;
            player.otherRb.angularVelocity = 0.0f;
        }
Example #3
0
        public override void Update(DefenderController_FSM player)
        {
            if (player.joint.enabled == false)
            {
                player.myRb.angularVelocity    = 0.0f;
                player.otherRb.angularVelocity = 0.0f;
            }

            player.joint.enabled = true;

            player.TransitionToState(player.push_State);
        }
Example #4
0
        public override void CleanUp(DefenderController_FSM player)
        {
            Color col = player.GetComponent <SpriteRenderer>().color;

            col.a = 1f;
            player.GetComponent <SpriteRenderer>().color = col;

            player.myRb.isKinematic = false;

            //player.joint.enabled = true;
            player.GetComponent <Collider2D>().enabled = true;

            oldSpriteObj.SetActive(true);
            newSpriteObj.SetActive(false);
        }
        public override void Update(DefenderController_FSM player)
        {
            player.myRb.AddRelativeForce(Vector2.right * player.pushPower * Time.fixedDeltaTime);

            //call the actions based on the probs
            if (frameCounter == 0)
            {
                //this is for preventing the angular velocity problem
                player.myRb.isKinematic = false;

                float prob = GetNaiveActionProb();

                /*if(prob <= 0.5f)
                 * {
                 *  //Default Action
                 *  DuellRotate(player);
                 *
                 * }*/
                if (prob <= 0.7f)
                {
                    //Push Action

                    // 1.) disable the joint
                    player.joint.enabled = false;

                    //2.) Push the other rb away
                    player.otherRb.AddRelativeForce(Vector2.left * 2);

                    //3.) change to the PassBlock state
                    player.TransitionToState(player.idle_state);
                }
                else
                {
                    //Knock Over Action
                    player.TransitionToState(player.down_state);
                }
                frameCounter = 50;
            }
            else
            {
                frameCounter--;
            }
        }
Example #6
0
        public override void EnterState(DefenderController_FSM player)
        {
            Color col = player.GetComponent <SpriteRenderer>().color;

            col.a = 0.3f;
            player.GetComponent <SpriteRenderer>().color = col;

            oldSpriteObj = player.transform.Find("ImgDir").gameObject;
            newSpriteObj = player.transform.Find("ImgDown").gameObject;

            //clean up the old object

            player.myRb.isKinematic     = true;
            player.myRb.velocity        = Vector2.zero;
            player.myRb.angularVelocity = 0;

            player.joint.enabled = false;
            player.GetComponent <Collider2D>().enabled = false;

            oldSpriteObj.SetActive(false);
            newSpriteObj.SetActive(true);
        }
Example #7
0
        public override void Update(DefenderController_FSM player)
        {
            //move first object
            float angle = Vector2.SignedAngle(player.otherObject.position - player.transform.position, new Vector2(1.0f, 0.0f));

            player.myRb.MoveRotation(-angle);

            if (frameCounter == 0)
            {
                //for the cross product we need to compare the vectors from the QB to the Receiver
                //to the Vector from the QB to the Defender
                Vector2 defenderQbVector = player.myRb.transform.position - player.QBtransform.position;
                Vector2 receiverQbVector = player.otherObject.transform.position - player.QBtransform.position;

                if (IsLeft(defenderQbVector, receiverQbVector))
                {
                    player.myRb.AddRelativeForce(Vector2.up * player.speed);
                    //Debug.Log("Is left");
                }
                else
                {
                    player.myRb.AddRelativeForce(Vector2.up * -player.speed);
                    //Debug.Log("Is right");
                }
                frameCounter = 20;
            }
            else
            {
                frameCounter--;
            }

            if (player.colliders.Length > 0)
            {
                //player.TransitionToState(player.snap_State);
                player.TransitionToState(player.push_State);
            }
        }
Example #8
0
 public override void EnterState(DefenderController_FSM player)
 {
     player.StartCoroutine(FinishResetDelay(player));
 }
 public override void CleanUp(DefenderController_FSM player)
 {
     player.myRb.angularVelocity = 0.0f;
     player.joint.enabled        = false;
 }
        /*private IEnumerator DuellRotateTest_Cor(DefenderController_FSM player)
         * {
         *  yield return new WaitForSeconds(0.3f);
         *
         *  //try to rotate just a little bit to simulate a arm battle
         *  //player.myRb.MoveRotation(Mathf.LerpAngle(player.myRb.rotation, player.myRb.rotation + 50, 2));
         *  float rotatePower = Random.Range(-1.0f, 1.0f);
         *
         *  player.myRb.AddTorque(rotatePower * 500, ForceMode2D.Force);
         *
         *  player.StartCoroutine(DuellRotateTest_Cor(player));
         *
         * }*/

        private void DuellRotate(DefenderController_FSM player)
        {
            float rotatePower = Random.Range(-1.0f, 1.0f);

            player.myRb.AddTorque(rotatePower * 500, ForceMode2D.Force);
        }
Example #11
0
 public abstract void OnCollisionEnter(DefenderController_FSM player);
Example #12
0
 public override void EnterState(DefenderController_FSM player)
 {
     player.StartCoroutine(BeIdle_Cor(player));
 }
Example #13
0
        private IEnumerator FinishResetDelay(DefenderController_FSM player)
        {
            yield return(new WaitForSeconds(0.5f));

            player.TransitionToState(player.passBlock_State);
        }
Example #14
0
 public override void OnCollisionEnter(DefenderController_FSM player)
 {
 }
Example #15
0
 public abstract void Update(DefenderController_FSM player);
Example #16
0
 public abstract void EnterState(DefenderController_FSM player);
Example #17
0
 public abstract void CleanUp(DefenderController_FSM player);
Example #18
0
 public override void Update(DefenderController_FSM player)
 {
 }
Example #19
0
 public override void EnterState(DefenderController_FSM player)
 {
 }
Example #20
0
 public override void CleanUp(DefenderController_FSM player)
 {
 }
Example #21
0
        private IEnumerator BeIdle_Cor(DefenderController_FSM player)
        {
            yield return(new WaitForSeconds(1f));

            player.TransitionToState(player.passBlock_State);
        }