Exemple #1
0
        public IEnumerator EmitDirection(HatDirection direction)
        {
            output.SetHatDirection(hatNumber, direction);
            yield return(new WaitForSecondsRealtime(0.1f));

            output.SetHatDirection(hatNumber, HatDirection.Neutral);
        }
 protected void SetHatDirection(uint hatNumber, HatDirection hatDirection)
 {
     if (output)
     {
         pressedHatDirections.Add(hatNumber);
         output.SetHatDirection(hatNumber, hatDirection);
     }
 }
Exemple #3
0
        public IEnumerator EmitDirection(HatDirection direction)
        {
            var output = vJoyInterface.instance;

            output.SetHatDirection(hatNumber, direction);
            yield return(new WaitForSecondsRealtime(0.1f));

            output.SetHatDirection(hatNumber, HatDirection.Neutral);
        }
Exemple #4
0
        protected void SetHatDirection(uint hatNumber, HatDirection hatDirection)
        {
            var output = vJoyInterface.instance;

            if (output)
            {
                pressedHatDirections.Add(hatNumber);
                output.SetHatDirection(hatNumber, hatDirection);
            }
        }
Exemple #5
0
        public void SetHatDirection(uint hatNumber, HatDirection dir)
        {
            int hatIndex = (int)hatNumber - 1;

            if (hatNumber == 0)
            {
                throw new System.IndexOutOfRangeException("Button number 0 is too low, button numbers are zero indexed");
            }
            if (hatIndex >= 4)
            {
                throw new System.IndexOutOfRangeException(string.Format("HAT index {0} is too high", hatIndex));
            }

            hat[hatIndex] = dir;
        }
        private void Update()
        {
            if (hatOwner)
            {
                //Make the Hat vanish upon pitfall, or when the player rolls if the hat is VANISH type
                HandleVanish();

                //Makes sure the hat gets it's position updated for player sprite flip
                if (lastCheckedPlayerFlipped != hatOwner.SpriteFlipped)
                {
                    UpdateOffsetForGunHandedness();
                }

                //UPDATE DIRECTIONS
                HatDirection checkedDir = FetchOwnerFacingDirection();
                if (checkedDir != currentDirection)
                {
                    UpdateHatFacingDirection(checkedDir);
                }

                HandleAttachedSpriteDepth(m_currentGunAngle.GetTypedValue <float>(hatOwner));
            }
        }
Exemple #7
0
 public void Direction(HatDirection direction)
 {
     StartCoroutine(EmitDirection(direction));
 }
        public HatDirection FetchOwnerFacingDirection()
        {
            HatDirection hatDir = HatDirection.NONE;

            if (hatOwner != null)
            {
                if (hatOwner.CurrentGun == null)
                {
                    Vector2 m_playerCommandedDirection      = commandedField.GetTypedValue <Vector2>(hatOwner);
                    Vector2 m_lastNonzeroCommandedDirection = lastNonZeroField.GetTypedValue <Vector2>(hatOwner);

                    float playerCommandedDir = BraveMathCollege.Atan2Degrees((!(m_playerCommandedDirection == Vector2.zero)) ? m_playerCommandedDirection : m_lastNonzeroCommandedDirection);

                    switch (playerCommandedDir)
                    {
                    case 90:
                        hatDir = HatDirection.NORTH;
                        break;

                    case 45:
                        hatDir = HatDirection.NORTHEAST;
                        break;

                    case -90:
                        hatDir = HatDirection.SOUTH;
                        break;

                    case -135:
                        hatDir = HatDirection.SOUTHWEST;
                        break;

                    case -180:
                        hatDir = HatDirection.WEST;
                        break;

                    case 180:
                        hatDir = HatDirection.WEST;
                        break;

                    case 135:
                        hatDir = HatDirection.NORTHWEST;
                        break;

                    case -45:
                        hatDir = HatDirection.SOUTHEAST;
                        break;
                    }
                    if (playerCommandedDir == 0 && hatOwner.Velocity != new Vector2(0f, 0))
                    {
                        hatDir = HatDirection.EAST;
                    }
                }
                else
                {
                    int FacingDirection = Mathf.RoundToInt(hatOwner.FacingDirection / 45) * 45;
                    switch (FacingDirection)
                    {
                    case 90:
                        hatDir = HatDirection.NORTH;
                        break;

                    case 45:
                        hatDir = HatDirection.NORTHEAST;
                        break;

                    case 0:
                        hatDir = HatDirection.EAST;
                        break;

                    case -45:
                        hatDir = HatDirection.SOUTHEAST;
                        break;

                    case -90:
                        hatDir = HatDirection.SOUTH;
                        break;

                    case -135:
                        hatDir = HatDirection.SOUTHWEST;
                        break;

                    case -180:
                        hatDir = HatDirection.WEST;
                        break;

                    case 180:
                        hatDir = HatDirection.WEST;
                        break;

                    case 135:
                        hatDir = HatDirection.NORTHWEST;
                        break;
                    }
                }
            }
            else
            {
                Debug.LogError("Attempted to get hatOwner facing direction with a null hatOwner!");
            }
            if (hatDir == HatDirection.NONE)
            {
                hatDir = HatDirection.SOUTH;
            }
            return(hatDir);
        }
        public void UpdateHatFacingDirection(HatDirection targetDir)
        {
            string animToPlay = "null";

            if (hatDirectionality == HatDirectionality.NONE)
            {
                animToPlay       = "hat_south";
                currentDirection = HatDirection.SOUTH;
            }
            else
            {
                switch (targetDir)
                {
                case HatDirection.SOUTH:
                    if (hatDirectionality != HatDirectionality.TWOWAYHORIZONTAL)
                    {
                        animToPlay = "hat_south";
                    }
                    break;

                case HatDirection.NORTH:
                    if (hatDirectionality != HatDirectionality.TWOWAYHORIZONTAL)
                    {
                        animToPlay = "hat_north";
                    }
                    break;

                case HatDirection.WEST:
                    if (hatDirectionality != HatDirectionality.TWOWAYVERTICAL)
                    {
                        animToPlay = "hat_west";
                    }
                    break;

                case HatDirection.EAST:
                    if (hatDirectionality != HatDirectionality.TWOWAYVERTICAL)
                    {
                        animToPlay = "hat_east";
                    }
                    break;

                case HatDirection.SOUTHWEST:
                    if (hatDirectionality == HatDirectionality.EIGHTWAY)
                    {
                        animToPlay = "hat_southwest";
                    }
                    else if (hatDirectionality != HatDirectionality.TWOWAYVERTICAL && frontDiagonalUseLeftRight)
                    {
                        animToPlay = "hat_west";
                    }
                    break;

                case HatDirection.SOUTHEAST:
                    if (hatDirectionality == HatDirectionality.EIGHTWAY)
                    {
                        animToPlay = "hat_southeast";
                    }
                    else if (hatDirectionality != HatDirectionality.TWOWAYVERTICAL && frontDiagonalUseLeftRight)
                    {
                        animToPlay = "hat_east";
                    }
                    break;

                case HatDirection.NORTHWEST:
                    if (hatDirectionality == HatDirectionality.SIXWAY || hatDirectionality == HatDirectionality.EIGHTWAY)
                    {
                        animToPlay = "hat_northwest";
                    }
                    else if (hatDirectionality != HatDirectionality.TWOWAYHORIZONTAL && backDiagonalUseNorth)
                    {
                        animToPlay = "hat_north";
                    }
                    break;

                case HatDirection.NORTHEAST:
                    if (hatDirectionality == HatDirectionality.SIXWAY || hatDirectionality == HatDirectionality.EIGHTWAY)
                    {
                        animToPlay = "hat_northeast";
                    }
                    else if (hatDirectionality != HatDirectionality.TWOWAYHORIZONTAL && backDiagonalUseNorth)
                    {
                        animToPlay = "hat_north";
                    }
                    break;

                case HatDirection.NONE:
                    ETGModConsole.Log("ERROR: TRIED TO ROTATE HAT TO A NULL DIRECTION!");
                    break;
                }
                currentDirection = targetDir;
            }
            if (animToPlay != "null")
            {
                hatSpriteAnimator.Play(animToPlay);
            }
        }