예제 #1
0
    private void OnPickableSpawned(PickableInWorld piw)
    {
        Vector2 pos = piw.transform.position;

        if (pos.x < min.x || pos.y < min.y || pos.x > max.x || pos.y > max.y)
        {
            piw.PickedUp(false);
            piw.DespawnPickable();
            return;
        }

        if (piw.Pickable.PickableType == PickableType.Weapon)
        {
            if (activeWeapons.Count > 0)
            {
                for (int i = 0; i < activeWeapons.Count; i++)
                {
                    if (activeWeapons[i])
                    {
                        activeWeapons[i].DespawnPickable();
                    }
                }
                activeWeapons.Clear();
            }
            activeWeapons.Add(piw);
        }
    }
예제 #2
0
 private void OnPickableDeSpawned(PickableInWorld piw)
 {
     if (piw.Pickable.PickableType == PickableType.Weapon)
     {
         activeWeapons.Remove(piw);
     }
 }
예제 #3
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);
     }
 }
예제 #4
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);
    }
예제 #5
0
    public static void Place(Pickable pickable, Vector3 position, bool isBuyable = false, bool playSpawnAnimation = true)
    {
        GameObject gObject = Instantiate(PickableDict.Instance.PickableInWorldPrefab);

        gObject.layer = LayerDict.Instance.GetPickableLayer();
        PositionConverter.AdjustZ(ref position);
        gObject.transform.position = position;
        PickableInWorld piw = gObject.GetComponent <PickableInWorld>();

        piw.pickable           = pickable;
        piw.isBuyable          = isBuyable;
        piw.playSpawnAnimation = playSpawnAnimation;
        NetworkServer.Spawn(gObject);
    }
예제 #6
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);
        }
    }
예제 #7
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);
        }
    }
예제 #8
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
    }
예제 #9
0
 public override void OnStartServer()
 {
     PickableInWorld.Place(weaponToDrop, spawnAt);
 }