Esempio n. 1
0
 /// <summary>
 /// Spawn starting items.
 /// </summary>
 public void SpawnItems(Pickable[] pickables, Vector3 vector3)
 {
     for (int i = 0; i < pickables.Length; i++)
     {
         Vector3 pos = vector3 + new Vector3(1.0f * (i - pickables.Length / 2.0f), 0.0f, 0.0f);
         //PickableInWorld.Place(pickables[i], MathUtil.RandomVector3(new Vector3(-1.0f, -1.0f), new Vector3(1.0f, 1.0f)) + vector3);
         PickableInWorld.Place(pickables[i], pos);
     }
 }
Esempio n. 2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (NetworkServer.active == false ||
            collision.gameObject.TryGetComponent(out Player _) == false)
        {
            return;
        }

        PickableInWorld.Place(RandomUtil.Element(toSpawnWeapons), transform.position + gunSpawnPoint);
    }
Esempio n. 3
0
    public void CmdDropItem(Item item, bool placeInWorld)
    {
        if (items.Contains(item) == false)
        {
            return;
        }

        item.OnDrop(player);
        items.Remove(item);
        player.Stats.OnItemsChanged(items);

        if (placeInWorld)
        {
            PickableInWorld.Place(item, transform.position);
        }
    }
Esempio n. 4
0
    /// <summary>
    /// Spawns the items that the players can buy.
    /// </summary>
    public void SpawnItems()
    {
        if (Player.LocalPlayer.isServer == false)
        {
            return;
        }

        itemPriceSigns = new GameObject[shopItems.Length];

        for (int i = 0; i < shopItems.Length; i++)
        {
            itemPriceSigns[i] = Instantiate(RegionDict.Instance.ShopItemPriceSign, locations[i] + Vector2.up * 1.5f, Quaternion.identity);
            ShopItemPriceDisplay sipd = itemPriceSigns[i].GetComponent <ShopItemPriceDisplay>();
            sipd.SetPrice(shopItems[i].Costs);
            Mirror.NetworkServer.Spawn(itemPriceSigns[i]);

            PickableInWorld.Place(shopItems[i], locations[i], true);
        }
    }
Esempio n. 5
0
    public void Swap(Weapon newWeapon, bool dropOldWeapon = true)
    {
        if (weapon != null && dropOldWeapon == true)
        {
            PickableInWorld.Place(weapon, transform.position, playSpawnAnimation: false);
        }

        weapon = newWeapon;
        if (!newWeapon)
        {
            remainingBullets = 0;
        }
        else
        {
            remainingBullets = weapon.MagazineSize;
            bulletLayerSpawn = LayerDict.Instance.GetBulletLayer(Health.EntityType, weapon.TargetMode);
        }
        // TODO: Reset all timed values and stuff
    }
Esempio n. 6
0
 public override void OnStartServer()
 {
     PickableInWorld.Place(weaponToDrop, spawnAt);
 }