Example #1
0
    void Update()
    {
        if (GameState.Current.State != GameState.GlobalState.Playing)
        {
            return;
        }

        if (State == PlayerState.Moving)
        {
            if (WalkTimer >= 0)
            {
                WalkTimer -= Time.deltaTime;
                if (WalkTimer < 0)
                {
                    anim.SetInteger(ANIM_PLAYERSTATE, ANIM_STAND);
                }
            }

            if (WalkTimer <= 0)
            {
                if (Mathf.Abs(Input.GetAxis(HORIZONTAL)) > 0)
                {
                    anim.SetInteger(ANIM_PLAYERSTATE, ANIM_WALK);
                    WalkTimer = WalkTimerMax;
                    tmpPos    = _t.position;
                    tmpScl    = _t.localScale;
                    tmpPos.x += Mathf.Sign(Input.GetAxis(HORIZONTAL)) * WalkStep;

                    if (tmpPos.x > MaxX)
                    {
                        tmpPos.x = MaxX;
                        State    = PlayerState.Shopping;
                        Store.Current.ResetForShopping();
                        Store.Current.Toggle(true);
                        anim.SetInteger(ANIM_PLAYERSTATE, ANIM_STAND);
                    }
                    else if (tmpPos.x < MinX)
                    {
                        tmpPos.x = MinX;
                        anim.SetInteger(ANIM_PLAYERSTATE, ANIM_WALK);
                    }

                    tmpScl.x = Mathf.Abs(tmpScl.x) * -Mathf.Sign(Input.GetAxis(HORIZONTAL));

                    _t.localScale = tmpScl;
                    _t.position   = tmpPos;
                }
            }

            if (PickTarget.Count > 0 && Input.GetButtonDown(FIRE))
            {
                foreach (IceFloe f in PickTarget)
                {
                    f.IsCleared = true;
                    SoundBoard.PlayIcePick();
                }
                CanFish = true;
            }
        }
    }