Пример #1
0
    public IEnumerator HandledHouse(House house, Vector2 local)
    {
        player.voice[2].Stop();
        currentStateName = "HandledHouse";
        while (true)
        {
            yield return(null);

            player.PositionInMap = house.LocalToMap(local);
            Position             = mapController.map.MapToWorldPoint(player.PositionInMap);
            Vector2Int side = house.PlayerSide(this);
            Dictionary <Vector2Int, string> sideAnimationNameMap = new Dictionary <Vector2Int, string>()
            {
                { new Vector2Int(-1, 0), "RightTop" },
                { new Vector2Int(1, 0), "LeftDown" },
                { new Vector2Int(0, 1), "RightDown" },
                { new Vector2Int(0, -1), "LeftTop" }
            };
            string clipName = sideAnimationNameMap[side];
            clipName += "Push";
            clipName += house.stateName == "Moving" ? "Walk" : "Stand";
            ClipPlayer.PlayClip(clipName);
            UnHandledInputProcess(house);
        }
    }
Пример #2
0
    public IEnumerator Idle()
    {
        currentStateName = "Idle";
        while (true)
        {
            yield return(null);

            player.PositionInMap = mapController.map.WorldToMapPoint(Position);
            if (!Application.isEditor || Application.isPlaying)
            {
                player.Update();
            }
            Vector2 direction = mapController.map.MapToWorldDirection(player.Forward);
            if (ClipPlayer != null && Time.timeScale > 0)
            {
                string clipName = "";
                if (direction.normalized.y > 0.8f)
                {
                    clipName = "Top";
                }
                else if (direction.normalized.y < -0.8f)
                {
                    clipName = "Down";
                }
                else if (direction.normalized.x > 0)
                {
                    clipName = "Right";
                }
                else
                {
                    clipName = "Left";
                }

                if (player.VelocityDir.magnitude > 0.1f)
                {
                    clipName += "Walk";
                }
                else
                {
                    clipName += "Stand";
                }
                ClipPlayer.PlayClip(clipName);
            }
            Position = mapController.map.MapToWorldPoint(player.PositionInMap);
        }
    }