Ejemplo n.º 1
0
    void FixedUpdate()
    {
        if (Player.Current.State == Player.PlayerState.Fishing && GameState.Current.State == GameState.GlobalState.Playing)
        {
            if (Mathf.Abs(Input.GetAxis(VERTICAL)) > 0)
            {
                SoundBoard.PlayCast(true);
                Player.Current.DoAnimation(Player.ANIM_DEPTH);
                Depth -= ReelSpeed * Input.GetAxis(VERTICAL) * Time.fixedDeltaTime * (Input.GetAxis(VERTICAL) > 0 ? ReelDownMultiplier : 1);
                if (Depth > MaxDepth)
                {
                    Depth = MaxDepth;
                    Player.Current.DoAnimation(Player.ANIM_STAND);
                }
                else
                {
                    Player.Current.DoAnimation(Player.ANIM_DEPTH);
                }
            }
            else
            {
                SoundBoard.PlayCast(false);
                Player.Current.DoAnimation(Player.ANIM_STAND);
            }
            if (Depth <= MinDepth)
            {
                Player.Current.State = Player.PlayerState.Moving;
                Player.Current.DoAnimation(Player.ANIM_STAND);
            }
            DrawFishingLine();
        }
        else if (Player.Current.State == Player.PlayerState.Reeling)
        {
            ReelAnimTimer += Time.fixedDeltaTime;
            Depth         -= ReelInSpeed * Time.fixedDeltaTime;
            if (Depth < MinDepth)
            {
                SoundBoard.PlayReel(false);
                Player.Current.State = Player.PlayerState.Moving;
                foreach (FishMouth fish in HookedFishes)
                {
                    Hook.Nibble();
                    GameState.Current.Moneys += fish.Fish.ScoreValue();
                    GameState.Current.Fishes.Remove(fish.Fish);
                    DestroyObject(fish.Fish.gameObject);
                }
                SoundBoard.PlayDing();
                HookedFishes.Clear();
                Player.Current.DoAnimation(Player.ANIM_STAND);
            }

            DrawFishingLine();
        }
        else
        {
            SoundBoard.PlayCast(false);
            SoundBoard.PlayReel(false);
            _lr.enabled = false;

            if (Player.Current.State == Player.PlayerState.Moving && Input.GetAxis(VERTICAL) < 0 && Player.Current.CanFish)
            {
                Depth = MinDepth;
                Player.Current.State = Player.PlayerState.Fishing;
                HookedFishes.Clear();
            }
        }
    }