示例#1
0
        public override void Update()
        {
            base.Update();

            if (isShooting)
            {
                shootTimer++;
                if (shootTimer >= SHOOT_WAIT_TIME)
                {
                    player.Direction = returnDirection;
                    player.BeginNormalState();
                }
            }
            else
            {
                // Update aiming controls.
                for (int dir = 0; dir < 4; dir++)
                {
                    if (Controls.Arrows[dir].IsPressed())
                    {
                        int goalAngle = Directions.ToAngle(dir);
                        int distCW    = Angles.GetAngleDistance(angle, goalAngle, WindingOrder.Clockwise);
                        int distCCW   = Angles.GetAngleDistance(angle, goalAngle, WindingOrder.CounterClockwise);

                        if (distCW != 0)
                        {
                            if (distCCW <= distCW)
                            {
                                angle = GMath.Wrap(angle + 1, Angles.AngleCount);                                 // Turn Counter-Clockwise
                            }
                            else
                            {
                                angle = GMath.Wrap(angle - 1, Angles.AngleCount);                                 // Turn Clockwise
                            }
                        }

                        if (angle % 2 == 0)
                        {
                            returnDirection = angle / 2;
                        }
                    }
                }

                // Make player and seed-shooter face the aim angle.
                player.Graphics.SubStripIndex = angle;
                player.ToolVisual.AnimationPlayer.SubStripIndex = angle;

                // Shoot when the button is released.
                if (!weapon.IsEquipped || !weapon.IsButtonDown())
                {
                    Shoot();
                }
            }
        }