public override void OnFlagCapture(Entities.Player Player, sbyte _flagState)
 {
     if (_flagState == -1) //the flag was neutral, add flag to the capturer team
     {
         if (Player.Team == Team.Derbaran)
         {
             _derbFlags++;
         }
         else
         {
             _niuFlags++;
         }
     }
     else   //flag stolen from the other team
     {
         if (Player.Team == Team.Derbaran)
         {
             _niuFlags--;
         }
         else
         {
             _derbFlags--;
         }
     }
 }
Beispiel #2
0
 void OnPlayerVsEnemyRelationshipCollisionOccurred (Entities.Player player, Entities.Enemy enemy) 
 {
     if(enemy.CurrentTarget == player && enemy.ExplodesOnDeath)
     {
         enemy.PerformExplode();
     }
 }
Beispiel #3
0
        public override void LoadContent()
        {
            base.LoadContent();

            GraphicsManager.InitGraphics();

            Entities.Player player = new Entities.Player();
            EntityMgr.Add(player);

            // Code in GameScreenSetup.cs
            SetupTileEngine();

            worldMap = new Map();
            SetupWorld();

            TileWidth  = worldMap.GetLayer(GameConstants.BOTTOM_LAYER).Tiles[0].Width;
            TileHeight = worldMap.GetLayer(GameConstants.BOTTOM_LAYER).Tiles[0].Height;
            int width  = worldMap.GetLayer(GameConstants.BOTTOM_LAYER).Width *TileSizeMultiplier;
            int height = worldMap.GetLayer(GameConstants.BOTTOM_LAYER).Height *TileSizeMultiplier;

            aStar = new AStar(GetMapData(), width, height, TileWidth / TileSizeMultiplier, TileHeight / TileSizeMultiplier);

            camera      = new Camera2D(Game1.Monitor, WorldWidth * 32, WorldHeight * 32);
            camera.Zoom = 2f;
        }
Beispiel #4
0
        public virtual void HandleExplosives(string[] blocks, Entities.Player p) //overriden by Explosive GameMode
        {
            byte _playerSlotId;
            byte _isExploding;
            byte _actionType;
            byte _itemId;

            byte.TryParse(blocks[0], out _playerSlotId);
            byte.TryParse(blocks[1], out _isExploding);
            byte.TryParse(blocks[2], out _actionType);
            byte.TryParse(blocks[3], out _itemId);

            if (_actionType == 2) //planting TMAs, no bombs in TDM or Conquest
            {
                if (_isExploding == 0)
                {
                    if (p.Class != Classes.Heavy)
                    {
                        p.User.Disconnect();
                    }
                }

                Room.Send((new Packets.Explosives(blocks)).BuildEncrypted());
            }
        }
        public bool SwitchSide(Entities.Player p)
        {
            lock (_playerLock) {
                byte maxTeamSize = (byte)(MaximumPlayers / 2);
                byte teamCount   = 0;
                Team newTeam     = Team.Derbaran;

                byte startScanIndex = 0;
                byte endScanIndex   = (byte)(MaximumPlayers / 2);

                if (p.Team == Team.Derbaran)
                {
                    teamCount      = (byte)Players.Select(n => n.Value).Where(n => n.Team == Team.NIU).Count();
                    startScanIndex = (byte)(MaximumPlayers / 2);
                    endScanIndex   = MaximumPlayers;
                    newTeam        = Team.NIU;
                }
                else
                {
                    teamCount = (byte)Players.Select(n => n.Value).Where(n => n.Team == Team.Derbaran).Count();
                }


                if (teamCount < maxTeamSize && !isClanWar)
                {
                    for (byte i = startScanIndex; i < endScanIndex; i++)
                    {
                        if (!Players.ContainsKey(i))
                        {
                            Entities.Player plr = null;
                            // Remove Old Player
                            if (Players.ContainsKey(p.Id))
                            {
                                Players.TryRemove(p.Id, out plr);
                            }

                            // Insert new Player
                            plr = p;

                            if (Players.TryAdd(i, plr))
                            {
                                if (p.Id == Master)
                                {
                                    Master = i;
                                }
                                plr.Set(i, newTeam);
                                return(true);
                            }
                            else
                            {
                                plr.User.Disconnect();
                            }

                            break;
                        }
                    }
                }
            }
            return(false);
        }
        internal static bool SetUserNickName(Context context, string nickname)
        {
            var sess = GetSessionById(context.Session);

            if (sess == null)
            {
                return(false);
            }
            var plr = sess.GetPlayerSafe(context.PlayerId);

            if (plr == null)
            {
                return(false);
            }
            plr.nickname = nickname;

            var newPlayer = new Entities.Player()
            {
                PlayerUuid = plr.PlayerId,
                GameRoomId = sess.RoomID,
                Name       = nickname,
                DeviceUuid = Guid.Parse(plr.DeviceId)
            };

            new PlayerRepository(Configuration).Create(newPlayer);

            plr.Id = newPlayer.Id;

            return(true);
        }
Beispiel #7
0
        void OnPlayerVsWeaponCollisionCollisionOccurred (Entities.Player player, Entities.WeaponDrop weaponDrop) 
        {
            if (player.InputDevice.DefaultPrimaryActionInput.WasJustPressed)
            {
                var weaponType = player.EquippedWeapon;

                int levelBefore = player.PlayerData.WeaponLevels.Single(
                    item => item.WeaponType == weaponType).CurrentWeaponLevel;

                player.ConsumeWeaponDrop(player.EquippedWeapon);

                int levelAfter = player.PlayerData.WeaponLevels.Single(
                    item => item.WeaponType == weaponType).CurrentWeaponLevel;

                weaponDrop.Destroy();

                var isLevelUp = levelBefore != levelAfter;

                ((GameScreenGumRuntime)GameScreenGum).RefreshExperienceBar(player, UpdateType.Interpolate, isLevelUp);
            }
            else
            {
                player.SetActionIconVisibility(true);
            }
        }
Beispiel #8
0
        public override void HandleExplosives(string[] blocks, Entities.Player p)
        {
            if (p.IsAlive && p.Health > 0)
            {
                sbyte byteType = -1;
                try {
                    sbyte.TryParse(blocks[2], out byteType);
                } catch { byteType = -1; }

                switch (byteType)  // TODO: Validate item id.
                {
                case 0: {
                    if (p.Team == Team.Derbaran)
                    {
                        if (!bombPlanted)
                        {
                            // STATICS //
                            p.BombsPlanted      += 1;
                            p.User.BombsPlanted += 1;

                            bombPlanted   = true;
                            bombDefused   = false;
                            bombSide      = sbyte.Parse(blocks[4]);
                            Room.DownTick = 45000;
                            Room.Send((new Packets.Explosives(blocks)).BuildEncrypted());
                        }
                    }
                    else if (p.Team == Team.NIU)
                    {
                        if (bombPlanted)
                        {
                            // STATICS //
                            p.BombsDefused      += 1;
                            p.User.BombsDefused += 1;

                            bombDefused = true;
                            Room.Send((new Packets.Explosives(blocks)).BuildEncrypted());
                        }
                    }

                    break;
                }

                case 1: {
                    break;
                }

                case 2: {
                    break;
                }

                default: {
                    p.User.Disconnect();     // Cheating?
                    break;
                }
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Check if the player can execute an artillery Attacker
        /// </summary>
        /// <param name="Attacker"></param>
        /// <param name="_weaponCode"></param>
        /// <returns>True if the player is allowed to perform the attack; false otherwise</returns>
        private bool isValidArtilleryAttack(Entities.Player Attacker)
        {
            if (Attacker.User.Inventory.Itemlist.Contains("DX01"))
            {
                return(true);
            }

            return(false);
        }
Beispiel #10
0
        private bool isFriendlyFire(Entities.Player Attacker, Entities.Vehicle Victim)
        {
            if (Room.FriendlyFire && Attacker.Team == Victim.Team && Room.Mode != Mode.Free_For_All)
            {
                return(true);
            }

            return(false);
        }
Beispiel #11
0
        public MapConsole(int width, int height) : base(width, height)
        {
            // Create the map
            IMapCreationStrategy <Map> mapCreationStrategy = new RandomRoomsMapCreationStrategy <Map>(width, height, 100, 15, 4);

            map = Map.Create(mapCreationStrategy);

            mapData = new SadConsole.CellAppearance[width, height];



            foreach (var cell in map.GetAllCells())
            {
                if (cell.IsWalkable)
                {
                    // Our local information about each map square
                    mapData[cell.X, cell.Y] = new MapObjects.Floor();
                    // Copy the appearance we've defined for Floor or Wall or whatever, to the actual console data that is rendered
                    mapData[cell.X, cell.Y].CopyAppearanceTo(this[cell.X, cell.Y]);
                }
                else
                {
                    mapData[cell.X, cell.Y] = new MapObjects.Wall();
                    mapData[cell.X, cell.Y].CopyAppearanceTo(this[cell.X, cell.Y]);
                }
            }

            // Create map effects
            explored            = new SadConsole.Effects.Recolor();
            explored.Background = Color.White * 0.3f;
            explored.Foreground = Color.White * 0.3f;
            explored.Update(10d);             // Trickery to force the fade to complete to the destination color.

            // Entities
            entities = new List <SadConsole.Game.GameObject>();

            // Create the player
            player = new Entities.Player();
            var tempCell = GetRandomEmptyCell();

            player.Position     = new Microsoft.Xna.Framework.Point(tempCell.X, tempCell.Y);
            player.RenderOffset = this.Position;
            entities.Add(player);

            // Create a hound
            GenerateHound();
            GenerateHound();
            GenerateHound();

            // Initial view
            UpdatePlayerView();

            // Keyboard setup
            SadConsole.Engine.Keyboard.RepeatDelay        = 0.07f;
            SadConsole.Engine.Keyboard.InitialRepeatDelay = 0.1f;
        }
 public bool ChangeSeat(byte _targetSeat, byte _oldSeat, Entities.Player NewOwner)
 {
     if (Seats[_oldSeat] != null && Seats[_targetSeat] != null && Seats[_targetSeat].UsedBy == null)
     {
         Seats[_oldSeat].EmptySeat();
         Seats[_targetSeat].EnterSeat(NewOwner);
         return(true);
     }
     return(false);
 }
        public void Save(Entities.Player instance, string name)
        {
            var definitionService = AstroSoarServiceProvider.DefinitionService;

            definitionService.SaveToBin(name, instance, DefinitionType.PlayerSave);

#if DEBUG
            definitionService.SaveToAssets(name, instance, DefinitionType.PlayerSave);
#endif
        }
Beispiel #14
0
        // Load
        public override void Load()
        {
            map             = new TileMap(bounds.Width, bounds.Height, 16);
            backgroundImage = new Image(Assets.level01background);

            Objects.Ball ball = new Objects.Ball();
            AddGameObject(ball, this, Geometry.RandomInt(0, 32), Geometry.RandomInt(0, 32));

            // Create tile sprites
            map.AddTileType("grass01", Assets.tiles, 1, 1, 16, false, "81d1ad");
            map.AddTileType("grass02", Assets.tiles, 2, 1, 16, false, "6aba96");
            map.AddTileType("grass03", Assets.tiles, 3, 1, 16, false, "56a783");
            map.AddTileType("grass04", Assets.tiles, 4, 1, 16, false, "489673");
            map.AddTileType("grassTopEdge", Assets.tiles, 9, 4, 16, false, "a0e8c8");
            map.AddTileType("flower01", Assets.tiles, 5, 1, 16, false, "ec907a");
            map.AddTileType("flower02", Assets.tiles, 12, 4, 16, false, "b96574");
            map.AddTileType("flower03", Assets.tiles, 9, 7, 16, false, "e0a878");
            map.AddTileType("rock", Assets.tiles, 12, 3, 16, true, "a8b8c8");
            map.CreateMapFromTexture(Assets.level01);

            // Place Trees
            foreach (Vector2 position in map.GetPositionsByColor(Assets.level01, "496a1a"))
            {
                AddGameObject(new Scenery.SmallPineTree(), this, (int)position.X, (int)position.Y);
            }

            // Place Objects
            string[,] colors = map.GetHexColorsFromTexture(Assets.level01);
            colors           = map.GetHexColorsFromTexture(Assets.level01objects);
            for (int x = 0; x < map.width; x++)
            {
                for (int y = 0; y < map.height; y++)
                {
                    string c = colors[x, y];
                    if (c == "496a1a")
                    {
                        Scenery.SmallPineTree tree = new Scenery.SmallPineTree();
                        AddGameObject(tree, this, x * map.tileWidth + 8, y * map.tileWidth + 8);
                    }
                }
            }

            // Place Textboxes
            Textbox text = new Textbox(Assets.font, 10, 10, "HEALTH: 100     MANA: 509");

            text.scale = 3;
            textboxes.Add(text);

            // Create Player
            player = new Entities.Player();
            AddGameObject(player, this, 128, 64);
            camera.parent = player.transform;

            loaded = true;
        }
Beispiel #15
0
 /// <summary>
 /// Checks if any attacks are colliding with players or enemies.
 /// </summary>
 /// <param name="a_char">reference to the currently active player.</param>
 public void CheckAttackCollision(ref Entities.Player a_char)
 {
     if (m_currentMap == 1)
     {
         CombatControl.CheckCollision(ref m_EnemyMasterList1, ref a_char);
     }
     else
     {
         CombatControl.CheckCollision(ref m_EnemyMasterList2, ref a_char);
     }
 }
Beispiel #16
0
 public override void OnFlagCapture(Entities.Player Player, sbyte _flagState)
 {
     if (Player.Team == Team.Derbaran)
     {
         _niuTicks--;
     }
     else
     {
         _derbTicks--;
     }
 }
 protected override void OnDeath(Entities.Player killer, Entities.Player target)
 {
     if (target.Team == Enums.Team.Derbaran)
     {
         _derbTicks--;
     }
     else
     {
         _niuTicks--;
     }
 }
 public override void OnPlayerSuicide(Entities.Player Player)
 {
     if (Player.Team == Team.Derbaran)
     {
         _derbTicks--;
     }
     else
     {
         _niuTicks--;
     }
 }
Beispiel #19
0
        public MapConsole(int width, int height)
            : base(width, height)
        {
            // Create the map
            IMapCreationStrategy<Map> mapCreationStrategy = new RandomRoomsMapCreationStrategy<Map>(width, height, 100, 15, 4);
            map = Map.Create(mapCreationStrategy);

            mapData = new SadConsole.CellAppearance[width, height];

            foreach (var cell in map.GetAllCells())
            {
                if (cell.IsWalkable)
                {
                    // Our local information about each map square
                    mapData[cell.X, cell.Y] = new MapObjects.Floor();
                    // Copy the appearance we've defined for Floor or Wall or whatever, to the actual console data that is rendered
                    mapData[cell.X, cell.Y].CopyAppearanceTo(this[cell.X, cell.Y]);
                }
                else
                {
                    mapData[cell.X, cell.Y] = new MapObjects.Wall();
                    mapData[cell.X, cell.Y].CopyAppearanceTo(this[cell.X, cell.Y]);
                }
            }

            // Create map effects
            explored = new SadConsole.Effects.Recolor();
            explored.Background = Color.White * 0.3f;
            explored.Foreground = Color.White * 0.3f;
            explored.Update(10d); // Trickery to force the fade to complete to the destination color.

            // Entities
            entities = new List<SadConsole.Game.GameObject>();

            // Create the player
            player = new Entities.Player();
            var tempCell = GetRandomEmptyCell();
            player.Position = new Microsoft.Xna.Framework.Point(tempCell.X, tempCell.Y);
            player.RenderOffset = this.Position;
            entities.Add(player);

            // Create a hound
            GenerateHound();
            GenerateHound();
            GenerateHound();

            // Initial view
            UpdatePlayerView();

            // Keyboard setup
            SadConsole.Engine.Keyboard.RepeatDelay = 0.07f;
            SadConsole.Engine.Keyboard.InitialRepeatDelay = 0.1f;
        }
 public int EnterVehicle(Entities.Player Player)
 {
     for (byte i = 0; i < SeatCount; i++)
     {
         if (Seats[i].UsedBy == null)
         {
             Seats[i].EnterSeat(Player);
             return(Seats[i].ID);
         }
     }
     return(-1);
 }
Beispiel #21
0
        private bool CanInFlictDamageTo(Entities.Player Attacker, Entities.Vehicle Vehicle)
        {
            bool _result = false;

            if (IsOperative(Vehicle) && Attacker.Health > 0 && Attacker.IsAlive)
            {
                if (Attacker.Team != Vehicle.Team || Room.FriendlyFire || Room.Mode == Mode.Free_For_All)
                {
                    _result = true;
                }
            }
            return(_result);
        }
Beispiel #22
0
        /// <summary>
        /// Checks collision of all attacks to all enemies/players.
        /// </summary>
        /// <param name="a_npcs">Reference to an npc list.</param>
        /// <param name="a_char">Reference to the active character.</param>
        public static void CheckCollision(ref List <Entities.NPCBad> a_npcs, ref Entities.Player a_char)
        {
            int counter = 0;

            if (m_attacks != null)
            {
                foreach (Attacks.Attack i in m_attacks)
                {
                    m_attacks[counter].CheckCollision(ref a_npcs, ref a_char);
                    counter++;
                }
            }
        }
        public sbyte GetSeatOf(Entities.Player Player)
        {
            sbyte _seat = -1;

            foreach (Objects.VehicleSeat Seat in Seats)
            {
                if (Seat.UsedBy == Player)
                {
                    _seat = (sbyte)Seat.ID;
                }
            }

            return(_seat);
        }
        public override void LoadContent()
        {
            var Services = owner.Services;
            var Content  = owner.Content;

            player = new Entities.Player(Services, Content.RootDirectory);

            currentLevel = new Level(Services, Content.RootDirectory, GameData.Instance.levelConstants.startLevelName, background);

            projectileManager = new ProjectileManager(Services, Content.RootDirectory);

            collisionManager = new CollisionManager();
            base.LoadContent();
        }
        protected override void OnDeath(Entities.Player killer, Entities.Player target)
        {
            if (killer != null)
            {
                if (killer.Kills > intCurrentLeaderKills)
                {
                    intCurrentLeaderKills = killer.Kills;
                }

                if (intCurrentLeaderKills >= intMaximumKills)
                {
                    this.Room.EndGame(Enums.Team.None);
                }
            }
        }
Beispiel #26
0
        public void CreatePlayer(PlayerInput input)
        {
            var playerEntity = _playeRepository.FirstOrDefault(a => a.PlayerName.Contains(input.PlayerName));

            if (playerEntity != null)
            {
                throw new UserFriendlyException("player exist");
            }

            playerEntity = new Entities.Player
            {
                PlayerName = input.PlayerName,
                MapID      = 1
            };
            _playeRepository.Insert(playerEntity);
        }
Beispiel #27
0
        public EndGame(Entities.Room r, Entities.Player[] players, Enums.Team winningTeam)
            : base((ushort)Enums.Packets.EndGame)
        {
            int[] teamKills  = new int[] { 0, 0 };
            int[] teamDeaths = new int[] { 0, 0 };

            teamKills[(byte)Enums.Team.Derbaran]  = players.Where(n => n.Team == Enums.Team.Derbaran).Sum(n => n.Kills);
            teamKills[(byte)Enums.Team.NIU]       = players.Where(n => n.Team == Enums.Team.NIU).Sum(n => n.Kills);
            teamDeaths[(byte)Enums.Team.Derbaran] = players.Where(n => n.Team == Enums.Team.Derbaran).Sum(n => n.Deaths);
            teamDeaths[(byte)Enums.Team.NIU]      = players.Where(n => n.Team == Enums.Team.NIU).Sum(n => n.Deaths);

            Append(Core.Constants.Error_OK);

            if (r.CurrentGameMode != null)                     //random crash
            {
                Append(r.CurrentGameMode.CurrentRoundTeamA()); //DERBARAN ROUNDS
                Append(r.CurrentGameMode.CurrentRoundTeamB()); //NIU ROUNDS
            }
            else
            {
                Fill(2, 0);
                Log.Instance.WriteDev("FFA Crash stopped"); //TODO
            }


            Append(teamKills[(byte)Enums.Team.Derbaran]);
            Append(teamDeaths[(byte)Enums.Team.Derbaran]);
            Append(teamKills[(byte)Enums.Team.NIU]);
            Append(teamDeaths[(byte)Enums.Team.NIU]);
            Append(0);
            Append(0);
            Append(players.Length);
            for (byte i = 0; i < players.Length; i++)
            {
                Entities.Player plr = players[i];
                Append(plr.Id);          // Slot
                Append(plr.Kills);       // Kills
                Append(plr.Deaths);      // Deaths
                Append(plr.Flags);       //Flags
                Append(plr.Points);      // Points
                Append(plr.MoneyEarned); // Dinar earned
                Append(plr.XPEarned);    // Exp earned
                Append(plr.User.XP);     // Player Exp
            }

            Append(r.Master);
        }
Beispiel #28
0
        void OnPlayerVsBulletExplosionCollisionCollisionOccurred (Entities.Player player, Entities.BulletExplosion bulletExplosion) 
        {
            if (bulletExplosion.TeamIndex != 0)
            {
                player.TakeDamage(bulletExplosion.DamageToDeal * CurrentMultipliers.EffectiveDamageMultiplier);

                var direction = Vector3.Right;

                if (bulletExplosion.X != player.X || bulletExplosion.Y != player.Y)
                {
                    var enemyToBullet = player.Position - bulletExplosion.Position;
                    enemyToBullet.Normalize();

                    player.Velocity += enemyToBullet * bulletExplosion.ExplosionForce;
                }
            }
        }           
Beispiel #29
0
 public HotbarSlotUI(Vector2 pos, int index, Entities.Player player)
 {
     if (slotPrefab == null)
     {
         slotPrefab = Resources.Load("Prefabs/ItemSlot") as GameObject;
     }
     this.player             = player;
     gameObject              = GameObject.Instantiate(slotPrefab, Vector3.zero, Quaternion.identity);
     rectTransform           = gameObject.GetComponent <RectTransform>();
     rectTransform.anchorMin = pos;
     rectTransform.anchorMax = pos + SLOT_SIZE;
     itemSlot           = gameObject.GetComponent <ItemSlot>();
     itemSlot.index     = index;
     itemSlot.inventory = player.inventory;
     itemSlot.OnClick   = ItemSlotClick;
     itemSlot.OnEnter   = ItemSlotEnter;
     itemSlot.OnExit    = ItemSlotExit;
 }
Beispiel #30
0
        public Game()
        {
            player = new Entities.Player(new Point(320, 240), 1.2);

            Asteroids = new List <Entities.Asteroid>();
            Bullets   = new List <Entities.Bullet>();
            boom      = new List <FX.Explosion>();

            shoot = new Sound("pew.wav");

            explode1 = new Sound("boom1.wav");
            explode2 = new Sound("boom2.wav");
            explode3 = new Sound("boom3.wav");
            explode4 = new Sound("boom4.wav");

            die = new Sound("die.wav");

            rnd = new Random();
        }
Beispiel #31
0
        /// <summary>
        /// Checks if the attack hit a player.
        /// </summary>
        /// <param name="a_npcs">List of all active NPCs on the map.</param>
        /// <param name="a_char">The player position, sent by reference.</param>
        public void CheckCollision(ref List <Entities.NPCBad> a_npcs, ref Entities.Player a_char)
        {
            int counter = 0;
            int damage  = 0;

            if (a_npcs != null)
            {
                foreach (Entities.NPCBad a in a_npcs)
                {
                    if (this.IsActive())
                    {
                        if (new Rectangle((int)m_position.X, (int)m_position.Y, m_anim[m_currentframe].Width, m_anim[m_currentframe].Height)
                            .Intersects(a_npcs[counter].GetRectangle()) && !this.ToPlayer())
                        {
                            bool melee = false;
                            if (a_char.GetClass() == Entities.Player.Class.Warrior)
                            {
                                melee = true;
                            }
                            if (a_npcs[counter].IsAlive())
                            {
                                damage = CombatControl.DealDamage(a_char, a_npcs[counter], melee, (int)m_modifier);
                                a_npcs[counter].ReduceCurrentHP(damage);
                                if (!a_npcs[counter].IsAlive())
                                {
                                    a_char.GainExp(a_npcs[counter].GetExpForKill());
                                }
                                this.Die();
                            }
                        }
                        if (new Rectangle((int)m_position.X, (int)m_position.Y, m_anim[m_currentframe].Width, m_anim[m_currentframe].Height)
                            .Intersects(a_char.GetRectangle()) && this.ToPlayer())
                        {
                            bool melee = true;
                            damage = CombatControl.DealDamage(a_npcs[counter], a_char, melee, 1);
                            a_char.ReduceCurrentHP(damage);
                            this.Die();
                        }
                    }
                    counter++;
                }
            }
        }
Beispiel #32
0
 //!--CLEANUP--!
 public bool ClearWorld()
 {
     //!--WORLD OBJECTS--!
     //sRoomBase = null;
     pPlayer = null;
     lObjects.Clear();
     lEnemies.Clear();
     lItems.Clear();
     return true;
 }
Beispiel #33
0
 public void CheckRemove(Vector2 v2_Mouse)
 {
     if (pPlayer != null && new Rectangle((int)v2_Mouse.X - 16, (int)v2_Mouse.Y - 16, 32, 32).Intersects(pPlayer.CollisionBox))
     {
         pPlayer = null;
     }
     //!--CHECK ITEMS--!
     for (int i = lObjects.Count - 1; i >= 0; i--)
     {
         if (new Rectangle((int)v2_Mouse.X - 4, (int)v2_Mouse.Y - 4, 8, 8).Intersects(lObjects.ElementAt(i).CollisionBox))
         {
             lObjects.RemoveAt(i);
         }
     }
     for (int i = lEnemies.Count - 1; i >= 0; i--)
     {
         if (new Rectangle((int)v2_Mouse.X - 4, (int)v2_Mouse.Y - 4, 8, 8).Intersects(lEnemies.ElementAt(i).CollisionBox))
         {
             lEnemies.RemoveAt(i);
         }
     }
     for (int i = lItems.Count - 1; i >= 0; i--)
     {
         if (new Rectangle((int)v2_Mouse.X - 4, (int)v2_Mouse.Y - 4, 8, 8).Intersects(lItems.ElementAt(i).CollisionBox))
         {
             lItems.RemoveAt(i);
         }
     }
 }
Beispiel #34
0
 //!--ENTITY ADDERS--!
 public void AddPlayer(Entities.Player p_Player)
 {
     pPlayer = p_Player;
 }
Beispiel #35
0
        public override void LoadContent(ContentManager Content)
        {
            Graphics.Textures.LoadContent(Content);

            base.LoadContent(Content);
            Engine.Paused = false;
            APEngine.SoundManager.SoundManager.LoadContent(Content);
            SoundManager = new APEngine.SoundManager.SoundManager();
            SoundManager.Volume = GameSettings.SFXVol;
            GossipManager = new Entities.Gossip.GossipManager();
            EditorMode = false;

            paused = Content.Load<Texture2D>("Data\\GFX\\Paused");
            Congrats = Content.Load<Texture2D>("Data\\GFX\\Congratz");
            lifeCounter = Content.Load<Texture2D>("Data\\GFX\\LivesIcon");
            ammoCounter = Content.Load<Texture2D>("Data\\GFX\\AmmoIcon");
            starPowerCounter = Content.Load<Texture2D>("Data\\GFX\\StarPowerBar");

            level = new Map.Level();
            level.CheckpointReached = false;

            EditUI = new Map.Editor.EditorUI(UIScale);
            EditUI.LoadContent(Content);

            lifeCountTimer = new UITimer(6000f);
            ammoTimer = new UITimer(6000f);
            starPowerTimer = new UITimer(6000f);
            uiBackgroundTimer = new UITimer(6500f);
            uiBackgroundPos = new Vector2(0, 0);

            projectiles = new List<Entities.Projectile>();
            entities = new List<Entities.Entity>();
            gameObjects = new List<GameObjects.GameObject>();
            mapGameObjects = new List<GameObjects.GameObject>();
            waterObjects = new List<GameObjects.Water>();
            clouds = new List<Map.Cloud>();

            powerUpsWindow = new UI.InfoBox(new Rectangle((int)(Engine.Monitor.VirtualWidth / 2) - 200, (int)(Engine.Monitor.VirtualHeight / 2) - 100, 400, 200));
            powerUpsWindow.LoadContent(Content);
            powerUpsWindow.Visible = false;

            projectiles.Clear();
            entities.Clear();
            gameObjects.Clear();

            backgroundFront = Content.Load<Texture2D>("Data\\GFX\\Forest\\backgroundFront");
            backgroundSky = Content.Load<Texture2D>("Data\\GFX\\Forest\\backgroundSkyNight");
            uiBackgroundTexture = Content.Load<Texture2D>("Data\\GFX\\UIBackground");

            FillClouds(10, Map.CloudType.Dark);

            Entities.Player player = new Entities.Player(level.PlayerSpawn, 1);
            player.Ability.HasDoubleJump = true;
            AddEntity(player);

            camera.LevelHeight = level.Height * Map.Tile.HEIGHT;
            camera.LevelWidth = level.Width * Map.Tile.WIDTH;

            healthText = Content.Load<Texture2D>("Data\\GFX\\healthText");
            healthBar = Content.Load<Texture2D>("Data\\GFX\\healthBar");

            textBox = new UI.GameFont(new Rectangle(100, Engine.Monitor.Height - 20, 800, 20), 800f);
            textBox.LoadContent(Content);
            textBox.Text = "Twitch: www.twitch.tv/corpseloleu | Twitter: @corpsegrindr";

            lifePos = new Vector2(10, 10);
            ammoPos = new Vector2(10, 15 + lifeCounter.Height * UIScale);
            starPowerPos = new Vector2(Engine.Monitor.VirtualWidth - 80 * UIScale, 12);

            lives = new UI.GameFont(new Rectangle((int)(lifePos.X + lifeCounter.Width * UIScale), (int)(lifePos.Y + 12 * UIScale), 200, 18), 200);
            lives.LoadContent(Content);
            lives.Text = player.Lives.ToString();

            ammo = new UI.GameFont(new Rectangle((int)(ammoPos.X + ammoCounter.Width * UIScale), (int)(ammoPos.Y + 8 * UIScale), 200, 18), 200);
            ammo.LoadContent(Content);
            ammo.Text = player.Clip.ToString();

            starPowerFont = new UI.GameFont(new Rectangle((int)(starPowerPos.X + starPowerCounter.Width * UIScale), (int)(starPowerPos.Y + 10 * UIScale), 100, 18), 100);
            starPowerFont.LoadContent(Content);
            starPowerFont.Text = player.Lives.ToString();

            AddGameObject(new GameObjects.DoubleJump(new Vector2(level.PlayerSpawn.X + 32 * 25, level.PlayerSpawn.Y + 16 - (32 * 5))));

            //level.CreateNewLevel(Map.Theme.JungleForest, 40, 40, "Empty Level");
            level.LoadMap("Empty Level");
        }
Beispiel #36
0
        public void RestartGame()
        {
            projectiles.Clear();
            entities.Clear();
            gameObjects.Clear();
            clouds.Clear();

            bool checkpoint = level.CheckpointReached;
            Vector2 spawnPos = level.PlayerSpawn;
            level = new Map.Level();
            level.CheckpointReached = checkpoint;
            level.PlayerSpawn = spawnPos;

            Entities.Player player = new Entities.Player(level.PlayerSpawn, 1);
            player.LoadContent(ScreenManager.Content);
            player.Health.Add(1);
            AddEntity(player);
        }
Beispiel #37
0
        public void LoadContent()
        {
            m_debug.LoadContent();

            var pp = m_graphics.PresentationParameters;

            // Create our entity world.
            m_world = new DynamicEntityWorld(m_game.Services);

            // Create the debug view.
            m_debugView = new DebugViewXNA(m_world.PhysicsWorld);
            m_debugView.LoadContent(m_graphics, m_content);

            // Create the camera.
            m_camera = new DefaultCamera(null, new Viewport(0, 0, pp.BackBufferWidth, pp.BackBufferHeight));
            m_cameraNode = m_world.Scene.Root.CreateChild("Camera");
            m_cameraNode.Attach(m_camera);

            // Create the player.
            m_player = new Entities.Player(
                new StaticSprite(Vector2.One * 10.0f, m_content.Load<Texture2D>(@"Sprites\Ship01"), "Player"));

            m_player.Attach(new Controllers.PlayerMovement(m_camera));
            m_world.Add(m_player);

            m_player.Position = new Vector2(0.0f, 0.0f);

            // Create the layers.
            m_playerLayer = new DefaultLayer(typeof(ISprite), "Player", 0.5f) { Scene = m_world.Scene };
            m_backgroundLayer = new DefaultLayer(0.0f) { Scene = m_world.Scene };

            // Create the background.
            var deepSpaceSprite = new StaticSprite(Vector2.One * 200.0f, m_content.Load<Texture2D>(@"Textures\Background01"), null) { BlendState = BlendState.Additive };
            var lessDeepSpaceSprite = new StaticSprite(Vector2.One * 400.0f, m_content.Load<Texture2D>(@"Textures\Background02"), null) { BlendState = BlendState.Additive };

            m_deepSpaceNode = m_cameraNode.CreateChild("Background_DeepSpace");
            m_deepSpaceNode.Depth = -1.0f; // Move the background into the back.
            m_deepSpaceNode.Attach(deepSpaceSprite);

            m_lessDeepSpaceNode = m_cameraNode.CreateChild("Background_LessDeepSpace");
            m_lessDeepSpaceNode.Depth = -0.9f; // Move the background into the back, but in front of the other background.
            m_lessDeepSpaceNode.Attach(lessDeepSpaceSprite);

            m_backgroundLayer.AddRenderable(deepSpaceSprite);
            m_backgroundLayer.AddRenderable(lessDeepSpaceSprite);

            // Create the dust cloud.
            var dustCloud = new Movables.DustCloud(100);

            m_dustCloudNode = m_world.Scene.Root.CreateChild("DustCloud");
            m_dustCloudNode.Depth = -0.8f;
            m_dustCloudNode.Attach(dustCloud);

            m_backgroundLayer.AddRenderable(dustCloud);

            // Create the planet.
            m_terrainLayer = new DefaultLayer(typeof(Entities.TerrainRegion), null, 0.0f) { Scene = m_world.Scene };
            m_miscLayer = new DefaultLayer(typeof(ISprite), "MISC_", -0.5f) { Scene = m_world.Scene };

            CreatePlanet();
        }