Ejemplo n.º 1
0
    private void onAssetsSet(RewardGrantedResponse response)
    {
        PlayerAssets assets = response.assets;

        Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.MyAssetsReceived(assets));
        handleCPResponse(response);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Process buying cargo from a merchant
    /// </summary>
    /// <param name="ship">The ship doing the buying</param>
    /// <param name="warehouse">The merchant doing the selling</param>
    /// <param name="assets">The player's wealth</param>
    /// <param name="id">The cargo to buy</param>
    /// <param name="count">The amount to buy</param>
    /// <returns>Successfulness</returns>
    public static bool ProcessBuy(CargoHold ship, Warehouse warehouse, PlayerAssets assets, Cargoes id, int count)
    {
        int price = warehouse.GetSellPrice(id, count);

        if (assets.cash < price)
        {
            return(false);
        }

        if (warehouse.GetWareQuantity(id) == 0)
        {
            return(false);
        }

        if (ship.availableSpace < count)
        {
            return(false);
        }

        assets.ModifyCash(-price);
        ship.Add(id, count);
        warehouse.ModifySellingWare(id, -count);
        warehouse.ModifyCash(price);

        return(true);
    }
Ejemplo n.º 3
0
        public void Show(SettlementService.Bank bank, PlayerAssets assets)
        {
            _bank   = bank;
            _assets = assets;

            UpdateDisplay();
        }
Ejemplo n.º 4
0
 // Use this for initialization
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag ("Player");
     PlayerAssets = player.GetComponent <PlayerAssets> ();
     GameObject feedbackObject = GameObject.FindGameObjectWithTag("Feedback");
     feedback = feedbackObject.GetComponent<Text>();
 }
Ejemplo n.º 5
0
 private void addRewardItems(PlayerAssets assets)
 {
     for (int i = 0; i < playerAssetsFieldInfo.Length; i++)
     {
         addRewardItem(playerAssetsFieldInfo[i].Name, playerAssetsFieldInfo[i].GetValue(assets));
     }
 }
        int CountCash(PlayerAssets assets)
        {
            var config = _context.GameConfig();

            var cash = assets.Cash;

            cash += assets.JailCards * 50;

            if (assets.Properties != null)
            {
                foreach (var propId in assets.Properties)
                {
                    var prop  = _context.GetTileComponent <Property>(propId);
                    var price = prop.BasePrice;
                    if (prop.IsMortgaged)
                    {
                        cash += (int)(prop.BasePrice * config.MortgageFee);
                    }
                    else
                    {
                        cash += prop.BasePrice;
                    }
                }
            }

            return(cash);
        }
Ejemplo n.º 7
0
	// Use this for initialization
	void Awake () {
		_instance = this;

		//new WindField();

		_cargoManager = new CargoManager();
		_timeManager = new TimeManager();
		_cargo = new CargoHold();
		_assets = new PlayerAssets();

		_settlements = FindObjectsOfType<Settlement>();

		var ais = FindObjectsOfType<AIController>();
		var list = new List<Ship>();

		foreach (var ai in ais) {
			list.Add(ai.GetComponent<Ship>());
		}

		_ais = list.ToArray();

		_playerStartPos = _playerShip.transform.position;
		_playerStartRot = _playerShip.transform.rotation;
		_cameraStartPos = Camera.main.transform.position;
		_cameraStartRot = Camera.main.transform.rotation;
	}
Ejemplo n.º 8
0
    /// <summary>
    /// Process selling cargo to a merchant
    /// </summary>
    /// <param name="ship">The ship doing the selling</param>
    /// <param name="warehouse">The merchant doing the buying</param>
    /// <param name="assets">The player's wealth</param>
    /// <param name="id">The cargo to sell</param>
    /// <param name="count">The amount to sell</param>
    /// <returns>Successfulness</returns>
    public static bool ProcessSell(CargoHold ship, Warehouse warehouse, PlayerAssets assets, Cargoes id, int count)
    {
        int price = warehouse.GetBuyPrice(id, count);

        if (warehouse.cash < price)
        {
            return(false);
        }

        if (warehouse.GetWantQuantity(id) == 0)
        {
            return(false);
        }

        if (ship.GetItemCount(id) < count)
        {
            return(false);
        }

        ship.Remove(id, count);
        warehouse.ModifyBuyingWare(id, -count);

        assets.ModifyCash(price);
        warehouse.ModifyCash(-price);

        if (!CargoManager.GetCargo(id).legal)
        {
            assets.ModifyReputation(price);
        }

        return(true);
    }
Ejemplo n.º 9
0
    // Use this for initialization
    void Awake()
    {
        player       = GameObject.FindGameObjectWithTag("Player");
        PlayerAssets = player.GetComponent <PlayerAssets> ();
        GameObject feedbackObject = GameObject.FindGameObjectWithTag("Feedback");

        feedback = feedbackObject.GetComponent <Text>();
    }
Ejemplo n.º 10
0
        string GetPlayerAssetsString(PlayerAssets playerAssets)
        {
            string player     = _formatOutput.FormattedString($"Assets from |player:{playerAssets.PlayerId}|\n");
            string cash       = $"Cash: {playerAssets.Cash}\n";
            string jailCards  = $"Jail cards: {playerAssets.JailCards}\n";
            string properties = "Properties:\n"
                                + GetPropertiesString(playerAssets.Properties, false).AddTwoSpacesAtNewLine();

            return(player + (cash + jailCards + properties).AddTwoSpacesAtNewLine());
        }
        void TransferToBank(PlayerAssets assets)
        {
            foreach (var propId in assets.Properties)
            {
                var prop = _context.GetTileComponent <Property>(propId);
                var dev  = _context.GetTileComponent <PropertyDevelopment>(propId);

                prop.IsMortgaged = false;
                prop.OwnerId     = null;

                if (dev != null)
                {
                    dev.HousesBuilt = 0;
                }
            }
        }
Ejemplo n.º 12
0
        public void Show(CargoHold ship, Warehouse warehouse, PlayerAssets assets)
        {
            base.Show();

            if (_listItemPrefab == null)
            {
                _listItemPrefab = Resources.Load("UI/Purchase Item");
            }

            _ship      = ship;
            _warehouse = warehouse;

            _settlementName.text = warehouse.settlement.name;

            UpdateMoneyCount();
            UpdateHoldCount();
            ShowSellScreen();
        }
        void TransferToPlayer(Player receiver, PlayerAssets assets)
        {
            var sender = _context.GetPlayer(assets.PlayerId);

            receiver.Cash += assets.Cash;
            sender.Cash   -= assets.Cash;

            receiver.JailCards += assets.JailCards;
            sender.JailCards   -= assets.JailCards;

            if (assets.Properties != null)
            {
                foreach (var propId in assets.Properties)
                {
                    var prop = _context.GetTileComponent <Property>(propId);
                    prop.OwnerId = receiver.Id;
                    receiver.Properties.Add(propId);
                    sender.Properties.Remove(propId);
                }
            }
        }
 public AssetTransferRequest(int?receiverId, PlayerAssets assets)
 {
     ReceiverId  = receiverId;
     this.Assets = assets;
 }
Ejemplo n.º 15
0
    // Use this for initialization
    void Start()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        assets = player.GetComponent <PlayerAssets> ();
    }
 public PrintPlayerAssets(PlayerAssets assets, OutputStream outputStream)
 {
     Assets       = assets;
     OutputStream = outputStream;
 }
Ejemplo n.º 17
0
 public MyAssetsReceived(PlayerAssets assets)
 {
     Assets = assets;
 }
        bool ProposedTrade(Player player, AiInfo aiInfo)
        {
            var setsMissingAProperty = _context.SetsMissingProperties(player);

            if (setsMissingAProperty.Count == 0)
            {
                return(false);
            }

            var possibleTraders = _context.GetAllPlayers()
                                  .Where(p => p.Id != player.Id)
                                  .Where(p => !aiInfo.TradeCooldowns.ContainsKey(p.Id));

            foreach (var trader in possibleTraders)
            {
                var interestingTradables = _context.TradableProperties(trader.Id)
                                           .Where(propId => setsMissingAProperty.Contains(_context.GetTileComponent <Property>(propId).SetId))
                                           .ToList();
                if (interestingTradables.Count == 0)
                {
                    continue;
                }

                var receiverAssetsSum = interestingTradables.Sum(x => _context.GetTileComponent <Property>(x).BasePrice);
                if (0.75f * receiverAssetsSum > player.Cash)
                {
                    continue;
                }

                var receiverAssets = new PlayerAssets(trader.Id, interestingTradables, 0, 0);
                var weights        = new List <(int, int)>(8);
                weights.Add((-1, 70));

                for (float coeff = 0.75f; coeff < 1.1f; coeff += 0.05f)
                {
                    var moneyGiven = receiverAssetsSum * coeff;
                    if (moneyGiven > player.Cash)
                    {
                        break;
                    }

                    var weight = (int)((coeff - 1) * 120);
                    weight += (int)(player.Cash / moneyGiven * 25);

                    weights.Add(((int)(moneyGiven), weight));
                }
                var choice = weights.ChaosChoice(aiInfo.ChaosFactor);
                if (choice == -1)
                {
                    continue;
                }

                var initiatorAssets = new PlayerAssets(player.Id, null, choice, 0);
                var offer           = new TradeOffer(initiatorAssets, receiverAssets);

                _context.Add(offer);
                aiInfo.TradeCooldowns.Add(trader.Id, 4);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 19
0
 public static void LoadPlayerColors()
 {
     PlayerAssets.ColorLoader(dataStreams(PlayersColorFiles.Select(x => new FileInfo(dataFolder + x))));
 }
Ejemplo n.º 20
0
 public static void LoadOrganizations()
 {
     PlayerAssets.OrganizationsLoader(dataStreams(OrganizationFiles.Select(x => new FileInfo(dataFolder + x))));
 }
Ejemplo n.º 21
0
 public static void LoadAis()
 {
     PlayerAssets.AILoader(loadFromDLLs <IOffscreenPlayerFactory>(pluginFolder + AIsFolder));
 }
Ejemplo n.º 22
0
 public TradeOffer()
 {
     InitiatorAssets = new PlayerAssets();
     ReceiverAssets  = new PlayerAssets();
 }
Ejemplo n.º 23
0
 void Start()
 {
     rb = GetComponent<Rigidbody>();
     anim = GetComponent <Animator> ();
     zombieAudio = GetComponent <AudioSource> ();
     //hitParticles = GetComponentInChildren <ParticleSystem> ();
     capsuleCollider = GetComponent <CapsuleCollider> ();
     player = GameObject.FindGameObjectWithTag ("Player");
     PlayerAssets = player.GetComponent <PlayerAssets> ();
     currentHealth = startingHealth;
     GameObject feedbackObject = GameObject.FindGameObjectWithTag("Feedback");
     feedback = feedbackObject.GetComponent<Text>();
 }
Ejemplo n.º 24
0
 public TradeOffer(PlayerAssets initiatorAssets, PlayerAssets receiverAssets)
 {
     InitiatorAssets = initiatorAssets;
     ReceiverAssets  = receiverAssets;
 }