Exemplo n.º 1
0
    private void AddResource(ResourceStorage storage, ResourceStorage selected, int value, int quantity)
    {
        ResourceType type = ResourceUtil.IntToType(value);

        // Check if the user has enough resources to increase
        if (quantity > 0 && !storage.HasResource(type, selected.GetResource(type) + quantity))
        {
            return;
        }

        selected.AddResource(type, quantity);
    }
Exemplo n.º 2
0
    public void StealResourceFromPlayer(Player stealee)
    {
        if (stealee.resources.IsEmpty())
        {
            return;
        }

        var rnd = new System.Random();
        var stealeeResources = stealee.resources;
        var from             = new ResourceStorage();
        var to         = new ResourceStorage();
        var namesCount = Enum.GetNames(typeof(ResourceType)).Length;
        Func <ResourceType> getType = () => (ResourceType)rnd.Next(0, namesCount);
        ResourceType        type    = getType();

        while (!stealeeResources.HasResource(type, 1))
        {
            type = getType();
        }
        to.AddResource(type, 1);
        gameController.ExecuteTrade(stealee, from, to);
        RaiseEvent(ActionType.ThiefStoleResource, new object[] { type, PhotonNetwork.LocalPlayer.NickName, stealee.name });
    }
Exemplo n.º 3
0
Arquivo: Miner.cs Projeto: i-h/ld46
 public void Collect(ResourceType type, int amount)
 {
     _resourceStorage.AddResource(type, amount);
     WorldUIManager.Instance.ResourceChanged(type, _resourceStorage.CheckResource(type));
 }