internal override void ActivateForPlayer(Player player, Vector2 location, ProjectileShotDirection direction)
 {
     player.AssignStatusEffect(new InvertGravityStatusEffect()
     {
         Duration = 5
     });
 }
Ejemplo n.º 2
0
 public PlayerShot(PowerupDefinition definition, Player owner, Vector2 location, ProjectileShotDirection direction)
 {
     ShotDefinition = definition;
     ShotOwner      = owner;
     ShotLocation   = location;
     ShotDirection  = direction;
 }
Ejemplo n.º 3
0
        internal override void ActivateForGhost(Ghost ghost, Vector2 location, ProjectileShotDirection direction)
        {
            var newObject = AttachableEffect.Res.Instantiate();

            Scene.Current.AddObject(newObject);
            newObject.Parent = ghost.GameObj;
            newObject.Transform.RelativePos = new Vector3(0, 0, -20);
            ghost.AssignStatusEffect(new ShieldEffect(newObject)
            {
                Duration = 5
            });
        }
Ejemplo n.º 4
0
        internal bool Use(Player player, Transform transform, ProjectileShotDirection direction, out RecordableAction resultingAction)
        {
            if (Uses > 0)
            {
                PlayerShot shot = new PlayerShot(PowerupType, player, transform.Pos.Xy, direction);
                shot.Do();

                resultingAction = shot;

                Uses--;
                return(true);
            }

            resultingAction = null;
            return(false);
        }
 internal override void ActivateForGhost(Ghost ghost, Vector2 location, ProjectileShotDirection direction)
 {
 }
Ejemplo n.º 6
0
        internal override void ActivateForPlayer(Player player, Vector2 location, ProjectileShotDirection direction)
        {
            if (ProjectilePrefab.IsAvailable)
            {
                var resultingObj = ProjectilePrefab.Res.Instantiate(new Vector3(location, 0));
                var projectile   = resultingObj.GetComponent <Projectile>();
                projectile.Owner              = player;
                projectile.Bounce             = true;
                projectile.OnHitPlayerEffects = OnPlayerHitEffects;

                var rigidbody = resultingObj.GetComponent <RigidBody>();

                Vector2 velocity   = rigidbody.LinearVelocity;
                float   totalSpeed = velocity.Length;
                switch (direction)
                {
                case ProjectileShotDirection.Left:
                    velocity = new Vector2(-totalSpeed, 0);
                    break;

                case ProjectileShotDirection.Up:
                    velocity = new Vector2(0, -totalSpeed);
                    break;

                case ProjectileShotDirection.Right:
                    velocity = new Vector2(totalSpeed, 0);
                    break;

                case ProjectileShotDirection.Down:
                    velocity = new Vector2(0, totalSpeed);
                    break;

                case ProjectileShotDirection.UpLeft:
                    velocity = new Vector2(-45, -45);
                    velocity.Normalize();
                    velocity *= totalSpeed;
                    break;

                case ProjectileShotDirection.UpRight:
                    velocity = new Vector2(45, -45);
                    velocity.Normalize();
                    velocity *= totalSpeed;
                    break;

                case ProjectileShotDirection.DownLeft:
                    velocity = new Vector2(-45, 45);
                    velocity.Normalize();
                    velocity *= totalSpeed;
                    break;

                case ProjectileShotDirection.DownRight:
                    velocity = new Vector2(45, 45);
                    velocity.Normalize();
                    velocity *= totalSpeed;
                    break;

                default:
                    break;
                }
                rigidbody.LinearVelocity = velocity;



                Scene.Current.AddObject(resultingObj);
            }
        }
Ejemplo n.º 7
0
 internal override void ActivateForGhost(Ghost ghost, Vector2 location, ProjectileShotDirection direction)
 {
     ActivateForPlayer(ghost.Owner, location, direction);
 }
Ejemplo n.º 8
0
 internal abstract void ActivateForGhost(Ghost ghost, Vector2 location, ProjectileShotDirection direction);
Ejemplo n.º 9
0
 internal abstract void ActivateForPlayer(Player player, Vector2 location, ProjectileShotDirection direction);
Ejemplo n.º 10
0
        private void CheckWeaponPowerup()
        {
            if (Definition.AssignedGamepad >= 0 && DualityApp.Gamepads[Definition.AssignedGamepad].IsAvailable || DualityApp.Keyboard.KeyHit(Duality.Input.Key.ControlLeft))
            {
                if (DualityApp.Gamepads[Definition.AssignedGamepad].ButtonHit(GamepadButton.X) || DualityApp.Keyboard.KeyHit(Duality.Input.Key.ControlLeft))
                {
                    if (WeaponPowerup != null && CanUsePickups)
                    {
                        float horizontalaxis = Movement.GatherHorizontalAxisValue();
                        float verticalaxis   = Movement.GatherVerticalAxisValue();

                        ProjectileShotDirection direction = (ProjectileShotDirection)(-1);

                        if (horizontalaxis < -Constants.Instance.GamepadDeadband)
                        {
                            if (verticalaxis < -Constants.Instance.GamepadDeadband && (!Collider.OnGround || Movement.GravityModifier > 0))
                            {
                                //up and to the left
                                direction = ProjectileShotDirection.UpLeft;
                            }
                            else if (verticalaxis > Constants.Instance.GamepadDeadband && (!Collider.OnGround || Movement.GravityModifier < 0))
                            {
                                direction = ProjectileShotDirection.DownLeft;
                            }
                            else
                            {
                                direction = ProjectileShotDirection.Left;
                            }
                        }
                        else
                        {
                            if (horizontalaxis > Constants.Instance.GamepadDeadband)
                            {
                                if (verticalaxis < -Constants.Instance.GamepadDeadband && (!Collider.OnGround || Movement.GravityModifier > 0))
                                {
                                    //up and to the left
                                    direction = ProjectileShotDirection.UpRight;
                                }
                                else if (verticalaxis > Constants.Instance.GamepadDeadband && (!Collider.OnGround || Movement.GravityModifier < 0))
                                {
                                    direction = ProjectileShotDirection.DownRight;
                                }
                                else
                                {
                                    direction = ProjectileShotDirection.Right;
                                }
                            }
                            else
                            {
                                if (verticalaxis < -Constants.Instance.GamepadDeadband && (!Collider.OnGround || Movement.GravityModifier > 0))
                                {
                                    direction = ProjectileShotDirection.Up;
                                }
                                else if (verticalaxis > Constants.Instance.GamepadDeadband && (!Collider.OnGround || Movement.GravityModifier < 0))
                                {
                                    direction = ProjectileShotDirection.Down;
                                }
                                else
                                {
                                    if (Movement.CurrentFacing == FacingEnum.Left)
                                    {
                                        direction = ProjectileShotDirection.Left;
                                    }
                                    else
                                    {
                                        direction = ProjectileShotDirection.Right;
                                    }
                                }
                            }
                        }

                        if (direction < 0)
                        {
                            if (Movement.CurrentFacing == FacingEnum.Left)
                            {
                                direction = ProjectileShotDirection.Left;
                            }
                            else
                            {
                                direction = ProjectileShotDirection.Right;
                            }
                        }


                        if (WeaponPowerup.Use(this, PowerupSpawnLocation, direction, out var resultingAction))
                        {
                            if (WeaponPowerup.PowerupType.Recordable)
                            {
                                TimeBody.ActionsThisFrame.Add(resultingAction);
                            }
                        }

                        if (WeaponPowerup.Uses <= 0)
                        {
                            WeaponPowerup = null;
                        }
                    }
                }
            }
        }