Exemplo n.º 1
0
 public virtual void Pickup(User user)
 {
     Pickups.Add(new Pickup()
     {
         CreatedAt = DateTime.Now, User = user, Issue = this
     });
 }
Exemplo n.º 2
0
 /// <summary>
 /// Applies the selected <see cref="LevelCompletionInfo"/>, or makes a new one if it is null.
 /// </summary>
 /// <param name="completionInfo">The level completion status to apply, null makes a new one</param>
 /// <param name="timeRemaining">The time remaining for this level</param>
 public void LoadSave(LevelCompletionInfo completionInfo = default, float timeRemaining = LevelCompletionInfo.DefaultTime)
 {
     if (completionInfo == default)
     {
         if (SaveFileManager.IsFileOpened)
         {
             CurrentCompletionInfo = Level.GetSaveFileInfo(SaveFileManager.Current);
         }
         else
         {
             CurrentCompletionInfo = new LevelCompletionInfo()
             {
                 LevelName      = Level.Name,
                 LevelWorldName = Level.LevelWorldName,
                 TimeRemaining  = timeRemaining
             }
         };
     }
     else
     {
         CurrentCompletionInfo = completionInfo;
     }
     if (CurrentCompletionInfo != null)
     {
         CurrentCompletionInfo.TimeRemaining    = timeRemaining;
         CurrentCompletionInfo.PattiesCollected = 0;
         CurrentCompletionInfo.BonusesCollected = 0;
     }
     if (!Pickups.ContainsKey("TIME"))
     {
         Pickups.Add("TIME", new WorldPickupDefinition(timeRemaining, timeRemaining));
     }
 }
Exemplo n.º 3
0
    public void RegisterPickup(TargetObject pickup)
    {
        if (pickup.gameMode != gameMode)
        {
            return;
        }

        Pickups.Add(pickup);

        NumberOfPickupsTotal++;
    }
Exemplo n.º 4
0
 /// <summary>
 /// Adds a pickup to the total tracked pickups in the level.
 /// </summary>
 /// <param name="pickupName"></param>
 public void AddPickup(string pickupName, int amount = 1, int DefaultAmountCollected = 0, int DefaultAmountTotal = 1)
 {
     if (Pickups.TryGetValue(pickupName, out var info))
     {
         Pickups[pickupName] = new WorldPickupDefinition(info.AmountCollected, info.AmountTotal + amount);
     }
     else
     {
         Pickups.Add(pickupName, new WorldPickupDefinition(DefaultAmountCollected, DefaultAmountTotal));
     }
 }
Exemplo n.º 5
0
        public ItemManager()
        {
            for (int i = 1; i <= 25; i++)
            {
                Pickup pickup = new Pickup(i);
                pickup.PropertyChanged += PickupOnPropertyChanged;
                Pickups.Add(pickup);
            }

            foreach (var item_entry in ItemNames)
            {
                int    id          = item_entry.Key;
                string name        = item_entry.Value;
                string description = ItemDescriptions[id];
                Items.Add(new Item(id, name, description));
            }
        }
Exemplo n.º 6
0
        public int CreatePickup(Vector3 pos, Vector3 rot, int pickupHash, int amount, int netHandle)
        {
            var newPickup = Function.Call <int>(Hash.CREATE_PICKUP_ROTATE, pickupHash, pos.X, pos.Y, pos.Z, rot.X, rot.Y, rot.Z, 512, amount, 0, true, 0);

            lock (HandleMap) HandleMap.Add(netHandle, newPickup);
            lock (Pickups) Pickups.Add(newPickup);
            var start = 0;

            while (Function.Call <int>(Hash.GET_PICKUP_OBJECT, newPickup) == -1 && start < 20)
            {
                start++;
                Script.Yield();
            }

            new Prop(Function.Call <int>(Hash.GET_PICKUP_OBJECT, newPickup)).FreezePosition = true;
            new Prop(Function.Call <int>(Hash.GET_PICKUP_OBJECT, newPickup)).IsPersistent   = true;

            return(newPickup);
        }
Exemplo n.º 7
0
        // Load the map
        private void CreateMap()
        {
            // Load map
            TmxFile2D mapFile = ResourceCache.GetTmxFile2D("test/map_1.tmx");

            if (mapFile == null)
            {
                throw new Exception("Map not found");
            }

            Node mapNode = scene.CreateChild("TileMap");

            mapNode.Position = new Vector3(0f, 0f, 10f);
            mapNode.SetScale(1f / 0.7f);

            tileMap         = mapNode.CreateComponent <TileMap2D>();
            tileMap.TmxFile = mapFile;

            // Load pickup sprites
            var weaponSprite = ResourceCache.GetSprite2D("map/levels/platformer-art-complete-pack-0/Request pack/Tiles/raygunBig.png");
            var armorSprite  = ResourceCache.GetSprite2D("map/levels/platformer-art-complete-pack-0/Request pack/Tiles/shieldGold.png");

            if (weaponSprite == null || armorSprite == null)
            {
                throw new Exception("Texture not found");
            }

            // Initialize map
            Random r = new Random();

            for (uint layerID = 0; layerID < tileMap.NumLayers; ++layerID)
            {
                TileMapLayer2D layer = tileMap.GetLayer(layerID);
                for (int x = 0; x < layer.Width; ++x)
                {
                    for (int y = 0; y < layer.Height; ++y)
                    {
                        Node n = layer.GetTileNode(x, y);
                        if (n == null)
                        {
                            continue;
                        }

                        Vector2 pos = tileMap.TileIndexToPosition(x, y);
                        pos /= 0.7f;
                        pos += new Vector2(0.5f, 0.5f);

                        // Solid Block
                        if (layer.GetProperty("Solid") == "True")
                        {
                            MapTile tile = new MapTile(pos);
                            Tiles.Add(tile);
                            collisionObjects.Add(tile);
                            continue;
                        }

                        // Spawner
                        switch (layer.GetProperty("Spawn"))
                        {
                        case "Player":
                            playerSpawns.Add(pos);
                            break;

                        case "Enemy":
                            enemySpawns.Add(pos);
                            break;

                        case "Weapon":
                            if (r.NextDouble() < weaponSpawnRate)
                            {
                                Pickups.Add(new PickupWeaponUpgrade(scene, weaponSprite, pos));
                            }
                            break;

                        case "Armor":
                            if (r.NextDouble() < armorSpawnRate)
                            {
                                Pickups.Add(new PickupArmor(scene, armorSprite, pos));
                            }
                            break;

                        default:
                            continue;
                        }

                        // Skipped if not a spawner
                        n.Remove();
                    }
                }
            }
        }
Exemplo n.º 8
0
        // This method loads the pickups
        // Recieves a line of serialized pickup data
        private void LoadPickups(string line)
        {
            InvokeOnMain(() =>
            {
                // Create images
                var weaponSprite = ResourceCache.GetSprite2D("map/levels/platformer-art-complete-pack-0/Request pack/Tiles/raygunBig.png");
                var armorSprite  = ResourceCache.GetSprite2D("map/levels/platformer-art-complete-pack-0/Request pack/Tiles/shieldGold.png");
                if (weaponSprite == null || armorSprite == null)
                {
                    throw new Exception("Texture not found");
                }

                // Clear Tilemap of old pickups
                for (uint layerID = 0; layerID < tileMap.NumLayers; ++layerID)
                {
                    TileMapLayer2D layer = tileMap.GetLayer(layerID);
                    for (int x = 0; x < layer.Width; ++x)
                    {
                        for (int y = 0; y < layer.Height; ++y)
                        {
                            Node n = layer.GetTileNode(x, y);
                            if (n == null)
                            {
                                continue;
                            }
                            if (layer.HasProperty("Spawn"))
                            {
                                n.Remove();
                            }
                        }
                    }
                }

                // Remove added pickups from map.
                foreach (Pickup p in Pickups)
                {
                    p.WorldNode.Remove();
                }
                Pickups.Clear();

                // Load each pickup
                string[] pickupsSplit = line.Split(';');
                foreach (var pickup in pickupsSplit.Take(pickupsSplit.Length - 1))
                {
                    Pickup pickupObj;

                    // determine type
                    var pickupType = pickup.Split(',')[0];
                    if (pickupType == "Royale_Platformer.Model.PickupArmor")
                    {
                        pickupObj = new PickupArmor();
                    }
                    else
                    {
                        pickupObj = new PickupWeaponUpgrade();
                    }

                    // determine position
                    var position = pickupObj.Deserialize(pickup);

                    // Load
                    if (pickupType == "Royale_Platformer.Model.PickupArmor")
                    {
                        Pickups.Add(new PickupArmor(scene, armorSprite, new Vector2(position.X, position.Y)));
                    }
                    else
                    {
                        Pickups.Add(new PickupWeaponUpgrade(scene, weaponSprite, new Vector2(position.X, position.Y)));
                    }
                }
            });
        }