SpawnItem() public method

public SpawnItem ( ) : void
return void
Ejemplo n.º 1
0
    protected virtual void BuildRoom(Room room, bool stairRoom, bool powerupRoom)
    {
        bool endRoom = stairRoom;

        GetRoomPattern(endRoom).Invoke(room);

        if (stairRoom)
        {
            room.hasStairs = true;
        }

        Vector2 wPos = room.WorldPos;

        if (powerupRoom)
        {
            spawner.SpawnItem(RandomFreePosition(room));
        }

        if (endRoom && floor.FloorID % 2 == 0)
        {
            SpawnBoss(room);
        }
        else
        {
            SpawnEnemies(room);
        }

        room.Lock();
    }
Ejemplo n.º 2
0
    private void CurrentWagon_ItemCreated(Item item, Vector3 position)
    {
        var spawnPosition = position;

        spawnPosition.z = transform.position.z;
        itemSpawner.SpawnItem(item, spawnPosition);
    }
Ejemplo n.º 3
0
 private void Update()
 {
     if (timer.Triggered())
     {
         float horizontalSpawnLocation = Random.Range(LeftWall.position.x, RightWall.position.x);
         ItemSpawner.SpawnItem(new Vector2(horizontalSpawnLocation, 12f));
         timer.ResetAndStart();
     }
 }
Ejemplo n.º 4
0
 public void StartGame()
 {
     StopAllCoroutines();
     m_PressEnter.enabled = false;
     InvokeRepeating("IncreaseSpikeSpeed", 0, 1);
     StartCoroutine(m_ItemSpawner.SpawnSpike());
     StartCoroutine(m_ItemSpawner.SpawnItem());
     m_hasStarted = true;
     InvokeRepeating("Timer", 1, 1);
 }
    // Generate all tiles for the given room.
    private void BuildRoom(Room room, bool stairRoom, bool powerupRoom)
    {
        // Add top and bottom walls.
        for (int x = 1; x <= Room.LimX - 1; x++)
        {
            room.SetTile(x, Room.LimY, TileType.Wall);
            room.SetTile(x, 0, TileType.Wall);
        }

        // Add left and right walls.
        for (int y = 1; y <= Room.LimY - 1; y++)
        {
            room.SetTile(0, y, TileType.Wall);
            room.SetTile(Room.LimX, y, TileType.Wall);
        }

        // Add corner walls. These could be baked into the above two loops, but I left them separate
        // since it depends on the art complexity.
        room.SetTile(0, Room.LimY, TileType.Wall);
        room.SetTile(Room.LimX, Room.LimY, TileType.Wall);
        room.SetTile(0, 0, TileType.Wall);
        room.SetTile(Room.LimX, 0, TileType.Wall);

        // Add floor.
        for (int y = 1; y <= Room.LimY - 1; y++)
        {
            for (int x = 1; x <= Room.LimX - 1; x++)
            {
                room.SetTile(x, y, TileType.Floor);
            }
        }

        int obstacleCount = Random.Range(0, 6);

        // Add some random obstacles for collision testing.
        for (int i = 0; i < obstacleCount; i++)
        {
            int x = Random.Range(2, Room.LimX - 1);
            int y = Random.Range(2, Room.LimY - 1);
            room.SetTile(x, y, TileType.Wall);
        }

        if (stairRoom)
        {
            room.SetTile(Room.LimX / 2, Room.LimY / 2, TileType.Stair);
        }

        Vector2 wPos = room.WorldPos;

        if (powerupRoom)
        {
            spawner.SpawnItem(wPos + RandomV2(3.0f, 3.0f, Room.LimX - 3.0f, Room.LimY - 3.0f));
        }
    }
Ejemplo n.º 6
0
        //------------------------------------------------------------------------------------------------------------------------
        //                                                  PopulateInventory()
        //------------------------------------------------------------------------------------------------------------------------



        private void populateInventory(int itemCount)
        {
            ItemSpawner itemSpawner = new ItemSpawner(new ItemFactoryLevel1());

            //ItemSpawner itemSpawner = new ItemSpawner(new ItemFactoryLevel2());



            for (int index = 0; index < itemCount; index++)
            {
                itemList.Add(itemSpawner.SpawnItem());
            }
        }
    void Start()
    {
        // Handle Level Generation
        levelManagement.generateLevel(Guid.NewGuid().ToString());

        //Spawn Players In

        List <int> playerIndexes = new List <int>();

        Debug.Log(SharedData.player1Joined);
        if (SharedData.player1Joined)
        {
            playerIndexes.Add(1);
        }
        if (SharedData.player2Joined)
        {
            playerIndexes.Add(2);
        }
        if (SharedData.player3Joined)
        {
            playerIndexes.Add(3);
        }
        if (SharedData.player4Joined)
        {
            playerIndexes.Add(4);
        }

        foreach (int index in playerIndexes)
        {
            Debug.Log(index);
            GameObject obj  = Instantiate(playerPrefab, levelManagement.GetGameObjectSpawnLocation(), Quaternion.identity);
            string     name = "Player " + index;
            Debug.Log(obj.transform.position);
            obj.GetComponent <PlayerMovement>().setChildTag(name);
            obj.GetComponent <PlayerInteraction>().tagSetup(index);
            obj.name = name;
            playerList[index - 1] = obj;
        }

        var values = Enum.GetValues(typeof(Item));

        foreach (Item item in values)
        {
            itemSpawner.SpawnItem(item, levelManagement.GetGameObjectSpawnLocation() + new Vector3(0, 1, 0));
        }
    }
Ejemplo n.º 8
0
    public void Die()
    {
        if (itemSpawner != null)
        {
            if (Random.Range(0, 2) == 0)
            {
                itemSpawner.SpawnItem(transform.position, Quaternion.identity);
            }
        }

        var deathbody = deathBoi.GetPooledInstance <PooledObject>();

        deathbody.transform.position = transform.position;
        deathbody.transform.rotation = transform.rotation;

        ReturnToPool();
    }
Ejemplo n.º 9
0
    private bool TryCreateItemForPlatform(Platform platform)
    {
        bool isItemCreated = false;

        if (platform.IsDestructible == false)
        {
            float randomValue = Random.value;

            if (randomValue < _itemProbability)
            {
                ItemType itemType = GenerateRandomItemType();

                GameObject item = _itemSpawner.SpawnItem(itemType, platform.transform);
                item.transform.position = CalculateItemPosition(platform.transform.position, _itemOffset);

                isItemCreated = true;
            }
        }

        return(isItemCreated);
    }
 private void dropItem(ItemSlot slot)
 {
     itemSpawner.SpawnItem(items[slot], gameObject.transform.position);
     setStatusOfPlayerParts(false, items[slot]);
     items.Remove(slot);
 }
Ejemplo n.º 11
0
 public static GameObject SpawnSmallChest(Vector2Int spawnLoc)
 {
     return(Instance.SpawnItem(Instance.SmallChest, spawnLoc));
 }
Ejemplo n.º 12
0
    public void SpawnItem_overNetwork(string itemToSpawn_prefab_name, Vector3 position)
    {
        GameObject itemToSpawn_prefab = ItemsManager.itemPrefabs_dict[itemToSpawn_prefab_name];

        itemSpawner.SpawnItem(itemToSpawn_prefab, position);
    }
 void Start()
 {
     itemSpawner.SpawnItem();
 }