// Start is called before the first frame update void Start() { mState = ANIKI_STATES.SANDWICH; mMarkerTransform = AnikiMarker.GetComponent <Transform>(); mTransform = GetComponent <Transform>(); mSprite = GetComponent <SpriteRenderer>(); }
public void Toggle() { if (mState == ANIKI_STATES.SANDWICH) { mTransform.localPosition = new Vector2(mFrontalPosition.x, mFrontalPosition.y); mState = ANIKI_STATES.FRONTAL; } else { mTransform.localPosition = new Vector2(mSandwichPosition.x, mSandwichPosition.y); mState = ANIKI_STATES.SANDWICH; } }
public void Toggle() { if (mState == ANIKI_STATES.SANDWICH) { mTransform.Rotate(new Vector3(0.0f, 0.0f, 90.0f)); mState = ANIKI_STATES.FRONTAL; } else { mTransform.Rotate(new Vector3(0.0f, 0.0f, -90.0f)); mState = ANIKI_STATES.SANDWICH; } }
// Update is called once per frame void Update() { if (mDead) { return; } mStateMachine.Update(); //character movement { //left if (Input.GetKey(KeyCode.LeftArrow)) { mHorizontal = -1; } else if (Input.GetKey(KeyCode.RightArrow))//right { mHorizontal = 1; } else//not moving left or right { mHorizontal = 0; } //up if (Input.GetKey(KeyCode.UpArrow)) { mVertical = 1; } else if (Input.GetKey(KeyCode.DownArrow))//down { mVertical = -1; } else//not moving up or down { mVertical = 0; } } //check for attack if (mBeamCounter > 0.0f && (mBeamCounter >= mBeamThreshold || (PLAYER_STATES)mStateMachine.GetStateNumber() == PLAYER_STATES.BEAM_ATTACK) && Input.GetKey(KeyCode.Space)) { mStateMachine.ChangeState((int)PLAYER_STATES.BEAM_ATTACK); //mAnimator.SetInteger("state", (int)PLAYER_STATES.BEAM_ATTACK); playBeam(); } else if (mChangeTimer <= 0.0f && Input.GetKey(KeyCode.X)) { mChangeTimer = mChangeDelay; mAnikiState = mAnikiState == ANIKI_STATES.FRONTAL ? ANIKI_STATES.SANDWICH : ANIKI_STATES.FRONTAL; mMarkerOne.Toggle(); mMarkerTwo.Toggle(); mAnikiOne.Toggle(); mAnikiTwo.Toggle(); } else if (Input.GetKey(KeyCode.C)) { mStateMachine.ChangeState((int)PLAYER_STATES.CHARGE); //mAnimator.SetInteger("state", (int)PLAYER_STATES.CHARGE); } else if (Input.GetKey(KeyCode.Z)) { mStateMachine.ChangeState((int)PLAYER_STATES.ATTACK); //mAnimator.SetInteger("state", (int)PLAYER_STATES.ATTACK); if (!mSoundDelay) { playShoot(); } } else { if (mHorizontal == 0 && mVertical == 0) { mStateMachine.ChangeState((int)PLAYER_STATES.IDLE); //mAnimator.SetInteger("state", (int)PLAYER_STATES.IDLE); } else { mStateMachine.ChangeState((int)PLAYER_STATES.MOVE); //mAnimator.SetInteger("state", (int)PLAYER_STATES.MOVE); } } switch ((PLAYER_STATES)(mStateMachine.GetStateNumber())) { case PLAYER_STATES.BEAM_ATTACK: if (mAnikiOne.mHp != 0 || mAnikiTwo.mHp != 0) { mBeamCounter -= mBeamDepletionRate * Time.deltaTime; if (mBeamCounter < 0.0f) { mBeamCounter = 0.0f; } } break; case PLAYER_STATES.CHARGE: mBeamCounter += mBeamChargeRate * Time.deltaTime; if (mBeamCounter > mBeamMax) { mBeamCounter = mBeamMax; } break; default: break; } mChangeTimer -= Time.deltaTime; if (mChangeTimer <= 0.0f) { mChangeTimer = 0.0f; } }
// Start is called before the first frame update void Start() { mState = ANIKI_STATES.SANDWICH; mTransform = GetComponent <Transform>(); mSandwichPosition = mTransform.localPosition; }