Exemple #1
0
 public override void onExit(PlayerStateController controller)
 {
     controller.hookLine.enabled = false;
     controller.hook.parent      = controller.transform;
     controller.isRetracting     = false;
     controller.hook.position    = controller.transform.position;
 }
    public override void handle_input(PlayerStateController controller)
    {
        controller.moveInput = Input.GetAxisRaw("Horizontal");
        controller.Flip();

        if (!controller.isRetracted)
        {
            // Render Hook
            if (controller.hookLine.enabled)
            {
                controller.hookLine.SetPosition(0, controller.transform.position);
                controller.hookLine.SetPosition(1, controller.hook.transform.position);
            }
        }
        else
        {
            controller.hookLine.enabled = false;
            controller.hook.parent      = controller.transform;
            controller.isRetracting     = false;
            controller.hook.position    = controller.transform.position;
        }

        // Decision to MovingState
        if (controller.isGrounded)
        {
            controller.ChangeState(controller.movingState);
        }
    }
    public override void Interact(PlayerStateController player)
    {
        if (!carried)
        {
            // Carry the loot!
            carried = true;

            // Reset rigidbody
            rigidbody.isKinematic     = true;
            rigidbody.velocity        = Vector3.zero;
            rigidbody.angularVelocity = Vector3.zero;

            // Disable collider
            meshCollider.enabled = false;

            player.Lift(gameObject);
        }
        else
        {
            // Drop the loot!
            carried = false;
            rigidbody.isKinematic = false;
            meshCollider.enabled  = true;

            // If i'm to be destroyed, prevent me from being interacted with
            if (destroy)
            {
                canInteract           = false;
                rigidbody.isKinematic = true;
            }

            player.Drop(gameObject);
            absorbTarget = transform.position + new Vector3(0, 3, 0);
        }
    }
 public override void onExit(PlayerStateController controller)
 {
     controller.animator.SetBool("Hide", false);
     controller.isHidden = false;
     controller.turtleSprite.sortingLayerName = "Player";
     controller.gameObject.layer = LayerMask.NameToLayer("Player");
 }
Exemple #5
0
    public static void Create(PlayerConfig config)
    {
        PlayerStateController controller = new PlayerStateController(config);

        Instance = controller;
        Reset();
    }
Exemple #6
0
 // Use this for initialization
 void Start()
 {
     controller      = gameObject.GetComponent <PlayerController>();
     stateController = gameObject.GetComponent <PlayerStateController>();
     anim            = gameObject.GetComponent <Animator>();
     spriteRend      = gameObject.GetComponent <SpriteRenderer>();
 }
Exemple #7
0
 private void DisplayVideo_Shown(object sender, EventArgs e)
 {
     _controller = new PlayerStateController(this);
     _controller.CurrentStateChanged += new EventHandler(ControllerCurrentStateChanged);
     RefreshInterface();
     BringToFront();
 }
Exemple #8
0
    protected override void Init()
    {
        base.Init();

        //get a reference to our input controller
        playerInputController = new PlayerInputController();
        playerInputController.playerCharacter = this;

        //Create our state controller to manage all our states
        playerStateController = new PlayerStateController(this);
        //init player to idle
        TransitionState(PlayerStates.SpearIdle);

        //get our hurtboxes
        hurtBoxController = GetComponentInChildren <HurtBoxController>();

        //get our blocking box and set to unactive
        blockBox = GetComponentInChildren <BlockBox>();
        blockBox.ToggleActive(false);

        //calculate gravity
        gravity         = -(2 * maxJumpHeight) / Mathf.Pow(timeToJumpApex, 2);
        maxJumpVelocity = Mathf.Abs(gravity) * timeToJumpApex;
        minJumpVelocity = Mathf.Sqrt(2 * Mathf.Abs(gravity) * minJumpHeight);
    }
Exemple #9
0
 private void Awake()
 {
     _stateController = GetComponentInParent <PlayerStateController>();
     playerMove       = GetComponentInParent <PlayerMovement>();
     player           = GetComponentInParent <PlayerAttributes>();
     cameraScript     = FindObjectOfType <SmoothFollow>();
 }
Exemple #10
0
 public Player()
 {
     Level                       = 0;
     HP                          = BasicMaxHP = 100;
     MP                          = BasicMaxMP = 100;
     WaitNoHealingTime           = 5;
     WaitHPHealingSpeed          = 0.5f;
     WaitMPHealingSpeed          = 0.25f;
     MoveSpeed                   = 15;
     GunBasicDamage              = 50;
     GunRange                    = 75;
     GunInterval                 = 0.2f;
     BulletAmount                = GunBasicBulletAmount = 15;
     GunBasicReloadInterval      = 2;
     HealPrepareTime             = 5;
     HealHPGain                  = 50;
     HealMPCost                  = 50;
     Entity                      = GameObject.Instantiate <GameObject>(Game.PlayerPrefab);
     Entity.transform.localScale = new Vector3(5, 5, 1);
     HealthBoard                 = GameObject.Instantiate <GameObject>(Game.HealthBoardPrefab);
     Controller                  = new PlayerStateController(this);
     PeaceStartTime              = Time.time;
     SetPosition(Vector3.zero);
     RefreshLevel();
 }
    public void KillPlayer(PlayerStateController killerState)
    {
        if (IsAlive && !knightAbility.IsDefending)
        {
            if (IsArmorBroken)
            {
                deathParticles.Play();
                killerState.playerScore++;
                IsAlive                = false;
                playerMov.isEnabled    = false;
                playerWeapon.isEnabled = false;
                playerSprite.enabled   = false;

                playerWeapon.DestroyWeapon();
                animator.SetBool("IsSwordTaken", false);

                StartCoroutine(Respawn());
            }
            else
            {
                IsArmorBroken           = true;
                playerMov.canDoublejump = true;
                animator.SetBool("IsArmorBroken", true);
            }
        }
    }
    void OnTriggerEnter(Collider other)
    {
        PlayerStateController player = other.GetComponentInParent <PlayerStateController>();
        Loot loot = player?.GetComponentInChildren <Loot>();

        if (!loot)
        {
            return;
        }

        loot.Absorb();

        // Add VFX
        if (GetIdVFX(player.transform) == -1) // Check that we have not added one already
        {
            Transform ray = Instantiate(drainRay, mainCrystal.transform.position, mainCrystal.transform.rotation).transform;
            ray.SetParent(mainCrystal);

            // 1 is the index of the first child (after the parent itself)
            Transform target = ray.GetComponentsInChildren <Transform>()[1];
            target.SetParent(loot.transform);
            target.localPosition = Vector3.zero;

            rays.Add(new Ray(ray, target));
            loot.target = target;
        }
    }
Exemple #13
0
    public void ChangeFavor()
    {
        PlayerStateController player = PlayerStateController.instance;

        if (clique == player.GetPlayerState())
        {
            if (personalAffinity < personalAffinityMax)
            {
                //This logic is so that we do not go above personal affinity max, and also so levelCliqueAffinity does not get
                //incremented any more than personal.
                float oldPersonalAffinity   = personalAffinity;
                float newPersonalAffinity   = Mathf.Min(personalAffinityMax, personalAffinity + incrementAffinitySpeed * Time.deltaTime);
                float deltaPersonalAffinity = newPersonalAffinity - oldPersonalAffinity;
                IncrementPersonalAffinity(deltaPersonalAffinity);
                LevelManager.instance.incrementCurrentAffinity(clique, deltaPersonalAffinity);
            }
        }
        else
        {
            float oldPersonalAffinity   = personalAffinity;
            float newPersonalAffinity   = Mathf.Max(0, personalAffinity + decrementAffinitySpeed * Time.deltaTime);
            float deltaPersonalAffinity = newPersonalAffinity - oldPersonalAffinity;
            IncrementPersonalAffinity(deltaPersonalAffinity);
            LevelManager.instance.incrementCurrentAffinity(clique, deltaPersonalAffinity);
        }
    }
 // Start is called before the first frame update
 void Start()
 {
     ps_controller = GetComponent <PlayerStateController>();
     //TODO: Load Max Health and mana instead of setting it.
     SetMaxHealth(maxHealth);
     SetMaxMana(maxMana);
 }
Exemple #15
0
 public override void update(PlayerStateController controller)
 {
     controller.hook.Translate(
         (controller.transform.position - controller.hook.transform.position).normalized * controller.speedHook * Time.fixedDeltaTime,
         Space.World
         );
 }
    private async void WeaponSwitching()
    {
        if (isSwitching)
        {
            var shootingState = PlayerStateController.FindState <ShootingState>();
            shootingState?.Stop();
            return;
        }

        if (Input.GetAxis("Mouse ScrollWheel") == 0)
        {
            return;
        }

        isSwitching = true;

        await new WaitForSeconds(timeToSwitch);

        if (ShootingState.currentGun == ShootingState.GunType.Primary)
        {
            ShootingState.currentGun = ShootingState.GunType.Secondary;
        }

        else if (ShootingState.currentGun == ShootingState.GunType.Secondary)
        {
            ShootingState.currentGun = ShootingState.GunType.Primary;
        }

        weaponSwitching.Switch();

        isSwitching = false;
    }
 // Use this for initialization
 void Start()
 {
     charge          = 0.0f;
     onGround        = false;
     rigidbody       = GetComponent <Rigidbody2D>();
     stateController = GetComponent <PlayerStateController>();
 }
    public override void handle_input(PlayerStateController controller)
    {
        if (Input.GetButtonDown("Fire2"))
        {
            controller.isRetracting = true;
        }

        // Render Hook
        controller.hookLine.SetPosition(0, controller.transform.position);
        controller.hookLine.SetPosition(1, controller.hook.transform.position);


        // Decision to FallingState

        if (controller.isRetracting)
        {
            controller.rb.isKinematic = false;
            // Push to hook
            controller.rb.AddForce(
                (controller.hook.position - controller.transform.position).normalized * controller.hookInertia * Time.deltaTime,
                ForceMode2D.Impulse
                );
            controller.ChangeState(controller.fallingState);
        }

        if (controller.isRetracted)
        {
            controller.rb.isKinematic   = false;
            controller.hookLine.enabled = false;
            controller.hook.parent      = controller.transform;
            controller.isRetracting     = false;
            controller.hook.position    = controller.transform.position;
            controller.ChangeState(controller.fallingState);
        }
    }
Exemple #19
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        _camera = GetNode <Camera2D>("../MainCamera");
        _camera.Call("SetFollow", this.GetPath());

        foreach (var node in Atmo.OgmoLoader.OgmoLoader.nodes)
        {
            node.Set("target", GetPath());
            Enemy.PlayerPath = GetPath();

            //node.Set("node", node.GetPath());
        }

        _hud              = GetNode <Control>("../CanvasLayer/HUD");
        Image             = GetNode <AnimatedSprite>("AnimatedSprite");
        _collisionShape2D = GetNode <CollisionShape2D>("CollisionShape2D");
        _overlord         = GetNode("/root/Overlord");

        BoxL = GetNode <Area2D>("SideBoxL");
        BoxR = GetNode <Area2D>("SideBoxR");
        BoxB = GetNode <Area2D>("BottomBox");

        this.Connect("HealthChanged", _hud, "on_set_health");
        this.Connect("AnimationChanged", _hud, "on_animation_changed");

        SetDeferred("Health", maxHealth);
        //Health = maxHealth;
        Power = 0;

        // Spice = 100;
        // Energy = 0f;
        MaxEnergy          = 3;
        EnergyRechargeRate = 2f;

        //JumpStrenth = 660;
        RunSpeed       = 200;
        DashMultiplier = 3.5f;
        HorizontalDrag = 50;
        Gravity        = Overlord.STANDARD_GRAVITY;

        // image.RenderStep = 1;

        // GameWorld.player = this;
        // Type = KQ.CollisionTypePlayer;

        Abilities = new Abilities(this);
        Abilities.GiveAllAbilities();
        MovementInfo = new MovementInfo(this);

        InputController       = new Controller();
        PlayerStateController = new PlayerStateController(new PSIdle(this));

        Image.Connect("animation_finished", this, "AnimationComplete");

        // AddResponse(PickupType.AirDash, OnAirDashPickup);
        // AddResponse(PickupType.AirJump, OnAirJumpPickup);
        // AddResponse(PickupType.Jump, OnJumpPickup);
        // AddResponse(PickupType.Dash, OnDashPickup);
    }
 public override void handle_input(PlayerStateController controller)
 {
     if (Input.GetButtonDown("Fire2") || Input.GetKeyDown(KeyCode.S))
     {
         Debug.Log("Move");
         controller.ChangeState(controller.movingState);
     }
 }
 void Start()
 {
     playerState = GetComponent <PlayerStateController>();
     playerState.SetState(PlayerState.Idle);
     rigidbody     = GetComponent <Rigidbody>();
     movementSpeed = walkMovementSpeed;
     facingRight   = true;
 }
 void OnTriggerEnter2D(Collider2D collidedObject)
 {
     if (collidedObject.tag == "Player")
     {
         Jump.UpdateEstadoJump();
         PlayerStateController.RotacionPlayer();
     }
 }
Exemple #23
0
 // Start is called before the first frame update
 void Start()
 {
     rid2d                 = GetComponent <Rigidbody2D>();
     animator              = GetComponent <Animator>();
     weaponPoint           = GetComponentInChildren <WeaponPoint>();
     isOutControl          = false;
     playerStateController = GetComponentInChildren <PlayerStateController>();
 }
    void Start()
    {
        _stateController = GetComponentInParent <PlayerStateController>();
        _anim            = GetComponentInChildren <Animator>();

        //Temp (animation's origins are slightly off (my b))
        transform.GetChild(0).localPosition = new Vector3(0, -1.05f, 0);
    }
Exemple #25
0
 void Start()
 {
     m_transform     = transform;
     m_body          = GetComponent <Rigidbody> ();
     oldPosition     = m_transform.position;
     stateController = GetComponent <PlayerStateController> ();
     overlap         = GetComponent <PlayerOverlap> ();
 }
 // Use this for initialization
 void Start()
 {
     playerPos   = GetComponent <Transform>();
     playerMov   = GetComponent <MovementScript>();
     playerCol   = GetComponent <BoxCollider2D>();
     playerState = GetComponent <PlayerStateController>();
     animator    = GetComponent <Animator>();
 }
    private void Awake()
    {
        Instance       = this;
        _startPosition = transform.position;

        IdleState   = new PlayerIdleState(this);
        AttackState = new PlayerAttackState(this, _damageForSlash, _playerAnimator, _moveSpeed, _targetTransform, _startPosition);
    }
    private void Start()
    {
        player     = GameObject.FindGameObjectWithTag(Tags.Player).GetComponent <Transform>();
        myJoystick = ETCInput.GetControlJoystick("MyJoystick");
        InitStateMachine();

        Instance = this;
    }
Exemple #29
0
 private static void InitPlayerValues()
 {
     playerDirection = null;
     playerSpeed     = null;
     mouseDown       = new MousePositionController();
     mouseUp         = new MousePositionController();
     playerState     = new PlayerStateController();
 }
Exemple #30
0
    public PlayerJumpingState(PlayerStateController playerController, StateMachine stateMachine)
    {
        this.playerController = playerController;
        this.stateMachine     = stateMachine;

        movementController  = playerController.movementController;
        animationController = playerController.animationController;
        animations          = (PlayerAnimations)animationController.animationsList;
    }
	//this compares the current state with the desired new state
	//checks if they are compatible and outputs a bool
	bool CheckForValidStatePair(PlayerStateController.playerStates newState)
	{
		bool returnVal = false;

		//Compare the current state against new desirable state
		switch(currentState)
		{
		case PlayerStateController.playerStates.idle:
			returnVal = true; //any state can take over from idle
			break;
		case PlayerStateController.playerStates.left:
			returnVal = true; //any state can take over from left
			break;
		case PlayerStateController.playerStates.right:
			returnVal = true; //any state can take over from right
			break;
		case PlayerStateController.playerStates.kill:
			if(newState == PlayerStateController.playerStates.resurrect) //only ressurect can take over from kill
				returnVal = true;
			else
				returnVal = false;
			break;
		case PlayerStateController.playerStates.resurrect:
			if(newState == PlayerStateController.playerStates.idle)
				returnVal = true;
			else
				returnVal = false;
			break;
		case PlayerStateController.playerStates.jump:
			if(newState == PlayerStateController.playerStates.landing || newState == PlayerStateController.playerStates.kill ||
			   newState == PlayerStateController.playerStates.firingWeapon)
				returnVal = true;
			else
				returnVal = false;
			break;
		}

		return returnVal;
	}
Exemple #32
0
	// Use this for initialization
	void Start () {
		playerState = GetComponent<PlayerStateController> ();
	}
 public InitialState(PlayerStateController playerStateController, VideoSource videoSource, IFrameDisplay frameDisplay)
     : base(playerStateController, videoSource, frameDisplay)
 {
 }
Exemple #34
0
 private void Awake()
 {
     psc = PlayerStateController.GetInstance();
 }
Exemple #35
0
 void onPlayerStateChange(PlayerStateController.playerStates newState)
 {
     currentPlayerState = newState;
 }
 public PauseReccordingState(PlayerStateController playerStateController, VideoSource videoSource, IFrameDisplay frameDisplay)
     : base(playerStateController, videoSource, frameDisplay)
 {
 }
    // onStateChange is called whenever we make a change to the player's state
    // from anywhere within the game's code.
    public void onStateChange(PlayerStateController.playerStates newState)
    {
        // If the current state and the new state are the same, abort - no need
        // to change to the state we're already in.
        if (newState == currentState)
            return;

        // Verify there are no special conditions that would cause this state to abort
        if (checkIfAbortOnStateCondition(newState))
            return;

        // Check if the current state is allowed to transition into this state. If it's not, abort.
        if (!checkForValidStatePair(newState))
            return;

        // Having reached here, we now know that this state change is allowed.
        // So let's perform the necessary actions depending on what the new state is.
        switch (newState)
        {
            case PlayerStateController.playerStates.idle:
                playerAnimator.SetBool("Walking", false);
                break;

            case PlayerStateController.playerStates.left:
                playerAnimator.SetBool("Walking", true);
                break;

            case PlayerStateController.playerStates.right:
                playerAnimator.SetBool("Walking", true);
                break;

            case PlayerStateController.playerStates.jump:
                if (playerHasLanded)
                {
                    // Use the jump direction variable to specify if the player
                    // should be jumping left, right, or verticle
                    float jumpDirection = 0.0f;

                    if (currentState == PlayerStateController.playerStates.left)
                        jumpDirection = -1.0f;
                    else if (currentState == PlayerStateController.playerStates.right)
                        jumpDirection = 1.0f;
                    else
                        jumpDirection = 0.0f;

                    // Apply the actual jump force
                    GetComponent<Rigidbody2D>().AddForce(new Vector2(jumpDirection * playerJumpForceHorizontal, playerJumpForceVertical));

                    playerHasLanded = false;
                    PlayerStateController.stateDelayTimer[(int) PlayerStateController.playerStates.jump] = 0f;
                }
                break;
            case PlayerStateController.playerStates.landing:
                playerHasLanded = true;
                PlayerStateController.stateDelayTimer[(int) PlayerStateController.playerStates.jump] = Time.time + 0.1f;
                break;
            case PlayerStateController.playerStates.falling:
                PlayerStateController.stateDelayTimer[(int) PlayerStateController.playerStates.jump] = 0f;
                break;
            case PlayerStateController.playerStates.kill:
                break;
            case PlayerStateController.playerStates.resurrect:
                transform.position = playerRespawnPoint.transform.position;
                transform.rotation = Quaternion.identity;
                GetComponent<Rigidbody2D>().velocity = Vector2.zero;
                break;
            case PlayerStateController.playerStates.firingWeapon:
                // Make the bullet object
                GameObject newBullet = (GameObject) Instantiate(bulletPrefab);

                // Set up the bullet's starting postion
                newBullet.transform.position = bulletSpawnTransform.position;

                // Acquire the PlayerBulletController component on the new object
                // so we can specify some data
                PlayerBulletController bullCon = newBullet.GetComponent<PlayerBulletController>();

                // Set the player object
                bullCon.playerObject = gameObject;

                // Launch the bullet!
                bullCon.lauchBullet();

                // With the bullet made, set the state of the player back to the
                // current state
                onStateChange(currentState);

                PlayerStateController.stateDelayTimer[(int) PlayerStateController.playerStates.firingWeapon] = Time.time + 0.25f;
                break;
        }

        // Store the current state as the previous state
        previousState = currentState;

        // And finally, assign the new state to the player object
        currentState = newState;
    }
    // checkIfAbortOnStateCondition allows us to do additional state verification, to see
    // if there is any reason this state should not be allowed to begin.
    bool checkIfAbortOnStateCondition(PlayerStateController.playerStates newState)
    {
        bool returnVal = false;

        switch (newState)
        {
            case PlayerStateController.playerStates.idle:
                break;

            case PlayerStateController.playerStates.left:
                break;

            case PlayerStateController.playerStates.right:
                break;

            case PlayerStateController.playerStates.jump:
                float nextAllowedJumpTime = PlayerStateController.stateDelayTimer[(int)PlayerStateController.playerStates.jump];

                if (nextAllowedJumpTime == 0.0f || nextAllowedJumpTime > Time.time)
                    returnVal = true;

                break;

            case PlayerStateController.playerStates.landing:
                break;

            case PlayerStateController.playerStates.falling:
                break;

            case PlayerStateController.playerStates.kill:
                break;

            case PlayerStateController.playerStates.resurrect:
                break;
            case PlayerStateController.playerStates.firingWeapon:
                if (PlayerStateController.stateDelayTimer[(int) PlayerStateController.playerStates.firingWeapon] > Time.time)
                    returnVal = true;
                break;
        }

        // Value of true means 'Abort'. Value of false means 'Continue'.
        return returnVal;
    }
    // Compare the desired new state against the current, and see if we are
    // allowed to change to the new state. This is a powerful system that ensures
    // we only allow the actions to occur that we want to occur.
    bool checkForValidStatePair(PlayerStateController.playerStates newState)
    {
        bool returnVal = false;

        // Compare the current against the new desired state.
        switch (currentState)
        {
            case PlayerStateController.playerStates.idle:
                // Any state can take over from idle.
                returnVal = true;
                break;

            case PlayerStateController.playerStates.left:
                // Any state can take over from the player moving left.
                returnVal = true;
                break;

            case PlayerStateController.playerStates.right:
                // Any state can take over from the player moving right.
                returnVal = true;
                break;

            case PlayerStateController.playerStates.jump:
                // The only state that can take over from Jump is landing
                // or kill.
                if (newState == PlayerStateController.playerStates.landing
                    || newState == PlayerStateController.playerStates.kill
                    || newState == PlayerStateController.playerStates.falling
                    || newState == PlayerStateController.playerStates.firingWeapon)
                    return true;
                else
                    return false;
                break;
            case PlayerStateController.playerStates.landing:
                if (newState == PlayerStateController.playerStates.left
                    || newState == PlayerStateController.playerStates.right
                    || newState == PlayerStateController.playerStates.idle
                    || newState == PlayerStateController.playerStates.firingWeapon)
                    returnVal = true;
                else
                    returnVal = false;
                break;
            case PlayerStateController.playerStates.falling:
                // The only states that can take over from falling are landing or kill
                if (
                    newState == PlayerStateController.playerStates.landing
                    || newState == PlayerStateController.playerStates.kill
                    || newState == PlayerStateController.playerStates.firingWeapon
                  )
                    returnVal = true;
                else
                    returnVal = false;
                break;
            case PlayerStateController.playerStates.kill:
                // The only state that can take over from kill is resurrect
                if (newState == PlayerStateController.playerStates.resurrect)
                    returnVal = true;
                else
                    returnVal = false;
                break;
            case PlayerStateController.playerStates.resurrect:
                // The only state that can take over from Resurrect is Idle
                if (newState == PlayerStateController.playerStates.idle)
                    returnVal = true;
                else
                    returnVal = false;
                break;
            case PlayerStateController.playerStates.firingWeapon:
                returnVal = true;
                break;
        }
        return returnVal;
    }
 /// <summary>
 /// シングルトンオブジェクトを返す
 /// </summary>
 /// <returns>プレイヤーの状態を管理するシングルトンオブジェクト</returns>
 public static PlayerStateController GetInstance()
 {
     if(_singleton == null)
         _singleton = new PlayerStateController();
     return _singleton;
 }
	//onStateChange is called when we need to change player's state
	public void OnStateChange(PlayerStateController.playerStates newState)
	{
		//if the current state and the new state are the same, do nothing
		if (newState == currentState)
			return;

		//can current state transition into a new state?
		if (!CheckForValidStatePair(newState))
			return;

		//if it passes the above check:
		switch(newState)
		{
		case PlayerStateController.playerStates.idle:
			break;
		case PlayerStateController.playerStates.left:
			break;
		case PlayerStateController.playerStates.right:
			break;
		case PlayerStateController.playerStates.kill:
			break;
		case PlayerStateController.playerStates.resurrect:
			transform.position = playerRespawnPoint.transform.position;
			transform.rotation = Quaternion.identity;
			rigidbody2D.velocity = Vector2.zero;
			break;
		case PlayerStateController.playerStates.jump:
			if(playerHasLanded)
			{
				float JumpDirection = 0.0f;
				if(currentState == PlayerStateController.playerStates.left)
					JumpDirection = -1.0f;
				else if (currentState == PlayerStateController.playerStates.right)
					JumpDirection = 1.0f;
				else
					JumpDirection = 0.0f;

				//Apply jump force
				rigidbody2D.AddForce(new Vector2(JumpDirection * playerJumpForceHorizontal, playerJumpForceVertical));

				playerHasLanded = false;
				PlayerStateController.stateDelayTimer[(int)PlayerStateController.playerStates.jump] = 0f;
			}
			break;
		}

		//update the state check variable
		currentState = newState;
	}
 bool checkForValidStatePair(PlayerStateController.PlayerStates newState)
 {
     bool returnVal = false;
     switch (currentState)
     {
         case PlayerStateController.PlayerStates.idle:
             returnVal = true;
             break;
         case PlayerStateController.PlayerStates.left:
             returnVal = true;
             break;
         case PlayerStateController.PlayerStates.right:
             returnVal = true;
             break;
         case PlayerStateController.PlayerStates.jump:
             if (newState == PlayerStateController.PlayerStates.landing
                 || newState == PlayerStateController.PlayerStates.kill
                 || newState == PlayerStateController.PlayerStates.firingWeapon)
                 returnVal = true;
             else
                 returnVal = false;
             break;
         case PlayerStateController.PlayerStates.landing:
             if (newState == PlayerStateController.PlayerStates.left
                 || newState == PlayerStateController.PlayerStates.right
                 || newState == PlayerStateController.PlayerStates.idle
                 || newState == PlayerStateController.PlayerStates.firingWeapon)
                 returnVal = true;
             else
                 returnVal = false;
             break;
         case PlayerStateController.PlayerStates.kill:
             if (newState == PlayerStateController.PlayerStates.resurrect)
                 returnVal = true;
             else
                 returnVal = false;
             break;
         case PlayerStateController.PlayerStates.resurrect:
             if (newState == PlayerStateController.PlayerStates.idle)
                 returnVal = true;
             else
                 returnVal = false;
             break;
         case PlayerStateController.PlayerStates.falling:
             returnVal = true;
             break;
         case PlayerStateController.PlayerStates.firingWeapon:
             returnVal = true;
             break;
     }
     return returnVal;
 }
    public void onStateChange(PlayerStateController.PlayerStates newState)
    {
        if (newState == currentState)
            return;
        if (!checkForValidStatePair(newState))
            return;
        if (checkIfAbortOnStateCondition(newState))
            return;
        switch (newState)
        {
            case PlayerStateController.PlayerStates.idle:
                playerAnimator.SetBool("Walking", false);
                break;
            case PlayerStateController.PlayerStates.left:
            case PlayerStateController.PlayerStates.right:
                playerAnimator.SetBool("Walking", true);
                break;
            case PlayerStateController.PlayerStates.jump:
                if (playerHasLanded)
                {
                    float jumpDirection = 0.0f;
                    if (currentState == PlayerStateController.PlayerStates.left)
                        jumpDirection = -1.0f;
                    else if (currentState == PlayerStateController.PlayerStates.right)
                        jumpDirection = 1.0f;
                    else
                        jumpDirection = 0.0f;

                    body.AddForce(new Vector2(jumpDirection * playerJumpForceHorizontal, playerJumpForceVertical));

                    playerHasLanded = false;
                    PlayerStateController.stateDelayTimer[(int)PlayerStateController.PlayerStates.jump] = 0f;
                }
                break;

            case PlayerStateController.PlayerStates.landing:
                playerHasLanded = true;
                PlayerStateController.stateDelayTimer[(int)PlayerStateController.PlayerStates.jump] = Time.time + 0.1f;
                break;
            case PlayerStateController.PlayerStates.falling:
                PlayerStateController.stateDelayTimer[(int)PlayerStateController.PlayerStates.jump] = 0f;
                break;
            case PlayerStateController.PlayerStates.kill:
                break;
            case PlayerStateController.PlayerStates.resurrect:
                transform.position = playerRespawnPoint.transform.position;
                transform.rotation = Quaternion.identity;
                body.velocity = Vector2.zero;
                break;
            case PlayerStateController.PlayerStates.firingWeapon:
                GameObject newBullet = (GameObject)Instantiate(bulletPrefab);
                newBullet.transform.position = bulletSpawnTransform.position;
                PlayerBulletController bullCon = newBullet.GetComponent<PlayerBulletController>();
                bullCon.player = gameObject;
                bullCon.launchBullet();
                onStateChange(currentState);
                PlayerStateController.stateDelayTimer[(int)PlayerStateController.PlayerStates.firingWeapon] = Time.time + 0.25f;
                break;
        }

        previousState = currentState;
        currentState = newState;
    }