Ejemplo n.º 1
0
 public void Add(Projectile item)
 {
     Debug.Assert(item != null, "item is null.");
     ProjectileList.Add(item);
     EntityList.Add(item);
     PhysicalObjectList.Add(item);
 }
Ejemplo n.º 2
0
 public void Remove(Projectile proj)
 {
     Debug.Assert(proj != null, "Projectile is null.");
     ProjectileList.Remove(proj);
     EntityList.Remove(proj);
     PhysicalObjectList.Remove(proj);
 }
        public SpaceDefenderPlayingState(StateManager gameStateManager)
        {
            _gameStateManager = gameStateManager;

            IDrawableGameComponent backdrop = new Backdrop(new Vector2(GameRoot.ScreenSize.X / 2.0f, GameRoot.ScreenSize.Y / 2.0f));
            _gameComponents.Add("backdrop", backdrop);

            var projectiles = new ProjectileList(Vector2.Zero);
            _gameComponents.Add("projectiles", projectiles);

            IDrawableGameComponent player = new Player(new Vector2(GameRoot.ScreenSize.X / 2.0f, GameRoot.ScreenSize.Y - 50.0f), projectiles);
            _gameComponents.Add("player", player);

            IDrawableGameComponent alien1 = new Alien(new Vector2(GameRoot.ScreenSize.X / 2.0f, GameRoot.ScreenSize.Y / 2.0f));
            _gameComponents.Add("alien1", alien1);

            IDrawableGameComponent alien2 = new Alien2(new Vector2(100.0f, 100.0f));
            _gameComponents.Add("alien2", alien2);

            //IDrawableGameComponent explosion = new AnimatedSprite("toets", Vector2.Zero, 1, 16, 1, 50);
            IDrawableGameComponent explosion = new Explosion(Vector2.Zero);
            explosion.IsAlive = false;
            _gameComponents.Add("explosion", explosion);

            IDrawableGameComponent hud = new Hud { Score = 0, Lives = 3 };
            _gameComponents.Add("hud", hud);

            _random = new Random();
        }
Ejemplo n.º 4
0
 public GameState()
 {
     Blocks = new BlockList();
     Effects = new EffectList();
     Units = new UnitList();
     Projectiles = new ProjectileList();
 }
Ejemplo n.º 5
0
 public void Shooting(Player Player)
 {
     if (Vector2.Distance(Player.Position, Position) <= Radius && ShootingCooldown <= 0)
     {
         Projectile projectile = new Projectile(Game1.redProTex, Position, Player.GetPlayerCenter(), Damage, Range, projectileSpeed);
         ShootingCooldown = 1000;
         ProjectileList.Add(projectile);
     }
 }
Ejemplo n.º 6
0
        /* Resets all entity lists to empty */
        private void ClearLists()
        {
            PlayerList.Clear();
            PlanetList.Clear();
            ProjectileList.Clear();
            BlackHoleList.Clear();
            BloodParticleList.Clear();

            EntityList.Clear();
            PhysicalObjectList.Clear();
            GravityPointList.Clear();
        }
Ejemplo n.º 7
0
 public bool Auto()
 {
     if (KeyMouseReader.mouseState.LeftButton == ButtonState.Pressed && firstWeapon.GetWeaponType() == WeaponTypes.auto)
     {
         if (firstWeapon.GetCooldown() <= 0)
         {
             projectile = new Projectile(Game1.yellowProTex, playerCenter, target, firstWeapon.GetDamage(), firstWeapon.GetRange(), firstWeapon.GetProjectileSpeed());
             ProjectileList.Add(projectile);
             firstWeapon.SetCooldown(firstWeapon.GetOriginCooldown());
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 8
0
 public bool SemiAuto()
 {
     if (KeyMouseReader.LeftClick() && firstWeapon.GetWeaponType() == WeaponTypes.semiAuto)
     {
         if (firstWeapon.GetCooldown() <= 0)
         {
             projectile = new Projectile(Game1.greenProTex, playerCenter, target, firstWeapon.GetDamage(), firstWeapon.GetRange(), firstWeapon.GetProjectileSpeed());
             ProjectileList.Add(projectile);
             firstWeapon.SetCooldown(firstWeapon.GetOriginCooldown());
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 9
0
 public void ProjectilePlayerCollision(Player player)
 {
     foreach (Projectile projectile in ProjectileList)
     {
         if (projectile.HitRect.Intersects(player.HitRect))
         {
             if (player.Damage())
             {
                 player.CurrHealth = (player.CurrHealth - projectile.GetDamage());
             }
             ProjectileList.Remove(projectile);
             return;
         }
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Makes the player shoot a projectile.
        /// </summary>
        /// <param name="shootFactor">The number of projectiles the player can shoot.</param>
        public void ShootBeam(float shootFactor)
        {
            if (CreateNewProjectile && CanShootProjectile && _Mana.mana >= _Mana.maxMana / shootFactor - 1)
            {
                _Mana.mana -= shootFactor;
                Projectile projectile = new Projectile(new Vector2(Position.X - 5, Position.Y + 11), Color.White, ProjectileAnimationSet, myGame, this);
                ProjectileList.Add(projectile);
                myGame.gameManager.shootSFX.Play(1f, 0f, 0f);
                HasShotProjectile = true;
            }

            if (_Mana.mana < 0)
            {
                _Mana.mana = 0;
            }
        }
Ejemplo n.º 11
0
 public void ProjectileNPCCollision(List <NPC> NPCs)
 {
     foreach (Projectile projectile in ProjectileList)
     {
         foreach (NPC npc in NPCs)
         {
             if (projectile.HitRect.Intersects(npc.HitRect) && !npc.IsDead)
             {
                 npc.CurrHealth    -= projectile.GetDamage();
                 npc.IsDamaged      = true;
                 npc.DamageCooldown = 100;
                 ProjectileList.Remove(projectile);
                 return;
             }
         }
     }
 }
Ejemplo n.º 12
0
    private void Start()
    {
        inventory = InventoryScript.instance;
        int numberOfSlots = System.Enum.GetNames(typeof(EquipmentSlot)).Length;

        //currentEquipment = new List<Equipment>(numberOfSlots);

        startGraphics = new Sprite[visibleGear.Length];
        SetVisibleGearSpriteRenderers();
        checkStarterGraphics();

        player = PlayerController.instance;
        stats  = PlayerStats.instance;

        weaponGlowSlot = player.transform.Find("Skeleton/Body/MainHand/MainItemGlow").GetComponent <SpriteRenderer>();

        listOfProjectiles = ProjectileList.instance;
    }
Ejemplo n.º 13
0
        /// <summary>
        /// Updates the Player class
        /// </summary>
        /// <param name="gameTime">To keep track of run time.</param>
        public override void Update(GameTime gameTime)
        {
            #region Updating Player Collision Points.
            playerCollisions.X = (int)Position.X;
            playerCollisions.Y = (int)Position.Y;
            #endregion

            #region Movement
            #region Detect Keys
            InputMethod(MovementKeys);
            #endregion

            #region Detect Collision
            foreach (Rectangle r in myGame.gameManager.platformRectangles)
            {
                CheckCollision(playerCollisions, r);
            }
            foreach (Rectangle r in myGame.gameManager.mapSegments)
            {
                CheckCollision(playerCollisions, r);
            }
            if (myGame.gameManager.level != 7 && (playerCollisions.TouchLeftOf(myGame.gameManager.mapSegments[1]) || playerCollisions.TouchTopOf(myGame.gameManager.mapSegments[1]) || playerCollisions.TouchRightOf(myGame.gameManager.mapSegments[1]) || playerCollisions.TouchBottomOf(myGame.gameManager.mapSegments[1])))
            {
                myGame.gameManager.wonLevel = true;
                Position = Vector2.Zero;
            }
            if (Position.Y >= myGame.gameManager.camera.Position.Y + myGame.gameManager.camera.Size.Y)
            {
                Dead   = true;
                Lives -= 1;
            }
            if (Lives <= 0)
            {
                myGame.SetCurrentLevel(Game1.GameLevels.LOSE);

                SetPosition(new Vector2(0, 0));
            }
            foreach (Enemy e in myGame.gameManager.cEnemyList)
            {
                if (playerCollisions.TouchLeftOf(e.playerCollisions) || playerCollisions.TouchTopOf(e.playerCollisions) || playerCollisions.TouchRightOf(e.playerCollisions) || playerCollisions.TouchBottomOf(e.playerCollisions))
                {
                    Dead   = true;
                    Lives -= 1;
                }
            }
            foreach (Enemy e in myGame.gameManager.sEnemyList)
            {
                if (playerCollisions.TouchLeftOf(e.playerCollisions) || playerCollisions.TouchTopOf(e.playerCollisions) || playerCollisions.TouchRightOf(e.playerCollisions) || playerCollisions.TouchBottomOf(e.playerCollisions))
                {
                    Dead   = true;
                    Lives -= 1;
                }
            }
            foreach (Enemy e in myGame.gameManager.tEnemyList)
            {
                if (playerCollisions.TouchLeftOf(e.playerCollisions) || playerCollisions.TouchTopOf(e.playerCollisions) || playerCollisions.TouchRightOf(e.playerCollisions) || playerCollisions.TouchBottomOf(e.playerCollisions))
                {
                    Dead   = true;
                    Lives -= 1;
                }
            }
            if (myGame.gameManager.BossCreated && !myGame.gameManager.bhEnemy.Dead)
            {
                if (playerCollisions.TouchLeftOf(myGame.gameManager.bflEnemy.GetPlayerRectangles()) || playerCollisions.TouchTopOf(myGame.gameManager.bflEnemy.GetPlayerRectangles()) || playerCollisions.TouchRightOf(myGame.gameManager.bflEnemy.GetPlayerRectangles()) || playerCollisions.TouchBottomOf(myGame.gameManager.bflEnemy.GetPlayerRectangles()))
                {
                    Dead   = true;
                    Lives -= 1;
                }
                if (playerCollisions.TouchLeftOf(myGame.gameManager.bfrEnemy.GetPlayerRectangles()) || playerCollisions.TouchTopOf(myGame.gameManager.bfrEnemy.GetPlayerRectangles()) || playerCollisions.TouchRightOf(myGame.gameManager.bfrEnemy.GetPlayerRectangles()) || playerCollisions.TouchBottomOf(myGame.gameManager.bfrEnemy.GetPlayerRectangles()))
                {
                    Dead   = true;
                    Lives -= 1;
                }
            }
            if (Dead == true)
            {
                ProjectileList.RemoveRange(0, ProjectileList.Count);
            }
            Lives = MathHelper.Clamp(Lives, 0, 3);
            #endregion

            UpdateGravity();
            #endregion

            #region Do Projectiles
            if (!ProjectileListCreated)
            {
                ProjectileAnimationSet.Add(new AnimationSet("IDLE", myGame.gameManager.ProjectileTexture, new Point(25, 25), new Point(1, 1), new Point(0, 0), 0, true));

                if (ProjectileAnimationSet != null && ProjectileList != null)
                {
                    ProjectileListCreated = true;
                }
            }

            foreach (Projectile p in ProjectileList)
            {
                p.Update(gameTime);
            }
            #endregion

            #region Do Animations
            if (isJumping || (isFalling && Direction.Y < DefaultGravityForce))
            {
                SetAnimation("JUMP");
            }
            if (CurrentAnimation.name == "IDLE")
            {
                Offset = new Vector2(10, 5);
            }
            if (CurrentAnimation.name == "SHOOT")
            {
                Offset = new Vector2(10, 5);
            }
            if (CurrentAnimation.name == "JUMP")
            {
                if (isFlipped)
                {
                    Offset = new Vector2(15, 5);
                }
                else
                {
                    Offset = new Vector2(25, 5);
                }
            }
            if (CurrentAnimation.name == "WALK")
            {
                if (isFlipped)
                {
                    Offset = new Vector2(0, 5);
                }
                else
                {
                    Offset = new Vector2(13, 5);
                }
            }
            #endregion

            #region Mana
            if (_Mana.mana < _Mana.maxMana)
            {
                if (!HasShotProjectile)
                {
                    _Mana.manaRechargeTime -= myGame.elapsedTime;
                }

                if (_Mana.mana <= 0)
                {
                    CanShootProjectile = false;
                }
                else if (_Mana.mana >= 0)
                {
                    CanShootProjectile = true;
                }

                if (_Mana.manaRechargeTime <= 0 && _Mana.mana < _Mana.maxMana && !HasShotProjectile)
                {
                    _Mana.manaInterval -= myGame.elapsedTime;

                    if (_Mana.manaInterval <= 0)
                    {
                        _Mana.mana        += 9.5f;
                        _Mana.manaInterval = 500;
                    }
                }

                if (_Mana.mana >= _Mana.maxMana || (HasShotProjectile && CanShootProjectile))
                {
                    _Mana.manaRechargeTime = 5000;
                }

                if (_Mana.mana > _Mana.maxMana)
                {
                    _Mana.mana = _Mana.maxMana;
                }
            }
            #endregion

            foreach (Projectile p in ProjectileList)
            {
                if (!p.visible)
                {
                    CreateNewProjectile = true;
                    ProjectileList.RemoveAt(0);
                    break;
                }
            }

            base.Update(gameTime);

            Position += Direction;

            PositionCenter = new Vector2(playerCollisions.Width / 2, playerCollisions.Height / 2);
        }
Ejemplo n.º 14
0
 public Player(Vector2 centerPosition, ProjectileList projectiles)
     : base(centerPosition)
 {
     _projectiles = projectiles;
 }
Ejemplo n.º 15
0
 private void Awake()
 {
     instance = this;
 }
 public void Spawn(IProjectile spawnable)
 {
     ProjectileList.Add(spawnable);
 }
Ejemplo n.º 17
0
        public override ProjectileList ThrowProjectile(CreepUnitList InRange)
        {
            ProjectileList Projectiles = new ProjectileList();
            if (InRange.Count > 3)
            {
                Random rand = new Random();
                int toAtk = rand.Next(2);
                toAtk += 2;

                for (int i = 0; i < toAtk; i++)
                {
                    Projectiles.Add(ThrowProjectile(InRange[i]));
                }
            }
            else
            {
                for (int i = 0; i < InRange.Count; i++)
                {
                    Projectiles.Add(ThrowProjectile(InRange[i]));
                }
            }

            return Projectiles;
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Constructor
        /// </summary>
        public DataController()
        {          
            // create lists
            roomObjects = new RoomObjectList(300);
            roomObjectsFiltered = new RoomObjectListFiltered(roomObjects);
            projectiles = new ProjectileList(50);
            onlinePlayers = new OnlinePlayerList(200);
            inventoryObjects = new InventoryObjectList(100);
            avatarCondition = new StatNumericList(5);
            avatarAttributes = new StatNumericList(10);
            avatarSkills = new SkillList(100);
            avatarSpells = new SkillList(100);
            avatarQuests = new SkillList(100);
            roomBuffs = new ObjectBaseList<ObjectBase>(30);
            avatarBuffs = new ObjectBaseList<ObjectBase>(30);
            spellObjects = new SpellObjectList(100);
            backgroundOverlays = new BackgroundOverlayList(5);
            playerOverlays = new ObjectBaseList<PlayerOverlay>(10);            
            chatMessages = new BaseList<ServerString>(101);
            gameMessageLog = new BaseList<GameMessage>(100);
            visitedTargets = new List<RoomObject>(50);
            clickedTargets = new List<uint>(50);
            actionButtons = new ActionButtonList();
            ignoreList = new List<string>(20);
            chatCommandHistory = new List<string>(20);

            // attach some listeners
            RoomObjects.ListChanged += OnRoomObjectsListChanged;
            Projectiles.ListChanged += OnProjectilesListChanged;
            ChatMessages.ListChanged += OnChatMessagesListChanged;

            // make some lists sorted
            OnlinePlayers.SortByName();
            AvatarSkills.SortByResourceName();
            AvatarSpells.SortByResourceName();
            SpellObjects.SortByName();
            
            // create single data objects
            roomInformation = new RoomInfo();
            lightShading = new LightShading(0, new SpherePosition(0, 0));
            backgroundMusic = new PlayMusic();
            guildInfo = new GuildInfo();
            guildShieldInfo = new GuildShieldInfo();
            guildAskData = new GuildAskData();
            diplomacyInfo = new DiplomacyInfo();
            adminInfo = new AdminInfo();
            tradeInfo = new TradeInfo();
            buyInfo = new BuyInfo();
            welcomeInfo = new WelcomeInfo();
            charCreationInfo = new CharCreationInfo();
            statChangeInfo = new StatChangeInfo();
            newsGroup = new NewsGroup();
            objectContents = new ObjectContents();
            effects = new Effects();
            lookPlayer = new PlayerInfo();
            lookObject = new ObjectInfo();
            clientPreferences = new PreferencesFlags();

            // some values
            ChatMessagesMaximum = 100;
            ChatCommandHistoryMaximum = 20;
            ChatCommandHistoryIndex = -1;
            AvatarObject = null;
            IsResting = false;
            SelfTarget = false;
            IsNextAttackApplyCastOnHighlightedObject = false;
            AvatarID = UInt32.MaxValue;
            TargetID = UInt32.MaxValue;
            ViewerPosition = V3.ZERO;
            UIMode = UIMode.None;
        }
Ejemplo n.º 19
0
        public void NewGame(GameDifficulty Difficulty)
        {
            map = new Map();
            CreepPath = new MapCoordList();
            PlayerUnits = new PlayerUnitDictionary();
            AttackInfos = new AttackInfoList();
            Projectiles = new ProjectileList();

            this.Difficulty = Difficulty;

            if (Difficulty == GameDifficulty.Easy)
            {
                Gold = 250;
                Crystal = 50;
            }
            else if (Difficulty == GameDifficulty.Medium)
            {
                Gold = 150;
                Crystal = 30;
            }
            else if (Difficulty == GameDifficulty.Hard)
            {
                Gold = 75;
                Crystal = 20;
            }

            Wave = 1;
            Score = 0;
            State = GameState.NoAttack;
            LastCombatLog = new CombatLog();
            LoadMap(MapFile);
        }