private void onAssetsSet(RewardGrantedResponse response) { PlayerAssets assets = response.assets; Service.Get <EventDispatcher>().DispatchEvent(new RewardServiceEvents.MyAssetsReceived(assets)); handleCPResponse(response); }
/// <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); }
public void Show(SettlementService.Bank bank, PlayerAssets assets) { _bank = bank; _assets = assets; UpdateDisplay(); }
// Use this for initialization void Awake() { player = GameObject.FindGameObjectWithTag ("Player"); PlayerAssets = player.GetComponent <PlayerAssets> (); GameObject feedbackObject = GameObject.FindGameObjectWithTag("Feedback"); feedback = feedbackObject.GetComponent<Text>(); }
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); }
// 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; }
/// <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); }
// Use this for initialization void Awake() { player = GameObject.FindGameObjectWithTag("Player"); PlayerAssets = player.GetComponent <PlayerAssets> (); GameObject feedbackObject = GameObject.FindGameObjectWithTag("Feedback"); feedback = feedbackObject.GetComponent <Text>(); }
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; } } }
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; }
// 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; }
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); }
public static void LoadPlayerColors() { PlayerAssets.ColorLoader(dataStreams(PlayersColorFiles.Select(x => new FileInfo(dataFolder + x)))); }
public static void LoadOrganizations() { PlayerAssets.OrganizationsLoader(dataStreams(OrganizationFiles.Select(x => new FileInfo(dataFolder + x)))); }
public static void LoadAis() { PlayerAssets.AILoader(loadFromDLLs <IOffscreenPlayerFactory>(pluginFolder + AIsFolder)); }
public TradeOffer() { InitiatorAssets = new PlayerAssets(); ReceiverAssets = new PlayerAssets(); }
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>(); }
public TradeOffer(PlayerAssets initiatorAssets, PlayerAssets receiverAssets) { InitiatorAssets = initiatorAssets; ReceiverAssets = receiverAssets; }