// ------------------------------------------- /* * Update */ private async void Update() { if (m_uid != -1) { while (m_events.Count > 0) { ItemMultiObjectEntry newMessage = m_events[0]; m_events.RemoveAt(0); await SendMatchStateAsync((long)newMessage.Objects[0], (string)newMessage.Objects[1], false); } } }
// ------------------------------------------- /* * Initialization of the element */ public override void Initialize(params object[] _list) { if ((m_dataEnemy == null) && (_list[0] != null)) { m_dataEnemy = ItemMultiObjectEntry.Parse((string)_list[0]); this.gameObject.tag = TAG_ENEMY; m_enter = (int)m_dataEnemy.Objects[1]; m_exit = (int)m_dataEnemy.Objects[2]; m_trajectory = new Vector2(m_enter, m_exit); m_animationDefinition = (string)m_dataEnemy.Objects[3]; m_speed = (float)(((float)((int)m_dataEnemy.Objects[4])) / 10f); m_life = (int)m_dataEnemy.Objects[5]; if (GameEventController.Instance.TotalPlayersInGame > 1) { float lastLife = m_life; m_life = m_life * GameEventController.Instance.TotalPlayersInGame; m_life = m_life * 0.9f; } // SET UP IN FIRST WAYPOINT m_waypointIndex = 0; List <Vector3> ways = EnemiesController.Instance.WaypointsEnemies(m_trajectory); m_waypoints = new List <Vector3>(); for (int i = 0; i < ways.Count; i++) { m_waypoints.Add(Utilities.ClonePoint(ways[i])); } m_waypointPosition = m_waypoints[m_waypointIndex]; transform.position = m_waypointPosition; FXController.Instance.NewFXAppearEnemy(m_waypointPosition); SoundsConstants.PlayFXEnemyAppear(); transform.localScale = new Vector3(GameConfiguration.CELL_SIZE, GameConfiguration.CELL_SIZE, GameConfiguration.CELL_SIZE); // UPDATE TO NEXT WAYPOINT UpdateToNextWaypoint(); InitializeCommon(); ChangeState(STATE_RUNNING); if (IsMine()) { NetworkEventController.Instance.DispatchNetworkEvent(NetworkEventController.EVENT_WORLDOBJECTCONTROLLER_INITIAL_DATA, NetworkID.GetID(), m_dataEnemy.ToString()); } } }
// ------------------------------------------- /* * Create a new enemy */ public void CreateNewEnemy(int _type, int _enter, int _exit, string _animation, int _speed, int _life) { if (GameEventController.Instance.IsGameMaster()) { ItemMultiObjectEntry initialData = new ItemMultiObjectEntry(_type, _enter, _exit, _animation, _speed, _life); if (GameEventController.Instance.TotalPlayersConfigurated != 1) { YourNetworkTools.Instance.CreateLocalNetworkObject(EnemyAssets[_type], YourNetworkTools.Instance.CreatePathToPrefabInResources(EnemyAssets[_type], true), initialData.ToString(), true, 10000, 10000, 10000); } else { GameObject newZombie = Instantiate(Resources.Load(YourNetworkTools.Instance.CreatePathToPrefabInResources(EnemyAssets[_type], true, true)) as GameObject); newZombie.GetComponent <IGameNetworkActor>().Initialize(initialData.ToString()); } } }
// ------------------------------------------- /* * GetAllTransactionsReal */ public void GetAllTransactionsReal() { AddLog("++INPUT TRANSACTIONS[" + EthereumController.Instance.InTransactionsHistory.Count + "]++"); for (int i = 0; i < EthereumController.Instance.InTransactionsHistory.Count; i++) { ItemMultiObjectEntry transaction = EthereumController.Instance.InTransactionsHistory[i]; AddLog(EthereumController.ToStringTransaction(transaction)); } AddLog("--OUTPUT TRANSACTIONS[" + EthereumController.Instance.OutTransactionsHistory.Count + "]--"); for (int i = 0; i < EthereumController.Instance.OutTransactionsHistory.Count; i++) { ItemMultiObjectEntry transaction = EthereumController.Instance.OutTransactionsHistory[i]; AddLog(EthereumController.ToStringTransaction(transaction)); } }
// ------------------------------------------- /* * OnBasicSystemEvent */ private void OnBasicSystemEvent(string _nameEvent, params object[] _list) { if (_nameEvent == BasicSystemEventController.EVENT_BASICSYSTEMEVENT_OPEN_INFO_IMAGE_SCREEN) { MenusScreenController.Instance.CreateNewScreen(ScreenImageView.SCREEN_IMAGE, UIScreenTypePreviousAction.KEEP_CURRENT_SCREEN, false, _list); } if (_nameEvent == FileItemView.EVENT_FILE_ITEM_SELECTED) { ItemMultiObjectEntry item = (ItemMultiObjectEntry)_list[0]; m_currentFileSelection = ((FileInfo)item.Objects[1]).FullName; } if (_nameEvent == FileItemView.EVENT_FILE_FOLDER_SELECTED) { ItemMultiObjectEntry item = (ItemMultiObjectEntry)_list[0]; UpdateListItems((DirectoryInfo)item.Objects[1]); } }
// ------------------------------------------- /* * Update */ public void Update() { if (m_uniqueNetworkID != -1) { while (m_events.Count > 0) { ItemMultiObjectEntry item = m_events[0]; m_events.RemoveAt(0); int uniqueNetworkID = (int)item.Objects[1]; string[] paramsEvent = new string[0]; if (item.Objects.Count > 3) { paramsEvent = (string[])item.Objects[3]; } DispatchEvent((string)item.Objects[0], uniqueNetworkID, (int)item.Objects[2], paramsEvent); } } }
// ------------------------------------------- /* * GetAllTransactionsReal */ public void GetAllTransactionsReal() { BitCoinController.Instance.GetAllInformation(m_publicKeyAddresToCheckHistory); AddLog("++INPUT TRANSACTIONS[" + BitCoinController.Instance.InTransactionsHistory.Count + "]++"); for (int i = 0; i < BitCoinController.Instance.InTransactionsHistory.Count; i++) { ItemMultiObjectEntry transaction = BitCoinController.Instance.InTransactionsHistory[i]; AddLog(BitCoinController.ToStringTransaction(transaction)); } AddLog("--OUTPUT TRANSACTIONS[" + BitCoinController.Instance.OutTransactionsHistory.Count + "]--"); for (int i = 0; i < BitCoinController.Instance.OutTransactionsHistory.Count; i++) { ItemMultiObjectEntry transaction = BitCoinController.Instance.OutTransactionsHistory[i]; AddLog(BitCoinController.ToStringTransaction(transaction)); } }
// ------------------------------------------- /* * Constructor */ public void Initialize(params object[] _list) { ItemMultiObjectEntry item = (ItemMultiObjectEntry)_list[0]; m_container = this.gameObject.transform; m_id = (string)item.Objects[0]; m_date = (DateTime)item.Objects[1]; m_amount = (decimal)item.Objects[2]; m_gas = (string)item.Objects[3]; m_title = (string)item.Objects[4]; List <ItemMultiTextEntry> transactionScriptPubKey = (List <ItemMultiTextEntry>)item.Objects[5]; string addresses = ""; for (int i = 0; i < transactionScriptPubKey.Count; i++) { ItemMultiTextEntry sitem = transactionScriptPubKey[i]; if (addresses.Length > 0) { addresses += ":"; } addresses += sitem.Items[1]; } m_container.Find("Target").GetComponent <Text>().text = EthereumController.Instance.AddressToLabelUpperCase(addresses.Split(':')); m_container.Find("Title").GetComponent <Text>().text = m_title; string dateTrimmed = m_date.ToString(); m_container.Find("Date").GetComponent <Text>().text = dateTrimmed; #if ENABLE_ETHEREUM m_container.Find("Bitcoins").GetComponent <Text>().text = Utilities.Trim(EthereumController.FromWei(new BigInteger(m_amount)).ToString()); #endif if (m_amount < 0) { m_container.GetComponent <Image>().color = new Color(188f / 255f, 83f / 255f, 141f / 255f); m_container.Find("IconsCalendar/Input").gameObject.SetActive(false); m_container.Find("IconsCalendar/Output").gameObject.SetActive(true); m_container.Find("IconsType/Sent").gameObject.SetActive(true); m_container.Find("IconsType/Received").gameObject.SetActive(false); } else { m_container.GetComponent <Image>().color = new Color(53f / 255f, 174f / 255f, 64f / 255f); m_container.Find("IconsCalendar/Input").gameObject.SetActive(true); m_container.Find("IconsCalendar/Output").gameObject.SetActive(false); m_container.Find("IconsType/Sent").gameObject.SetActive(false); m_container.Find("IconsType/Received").gameObject.SetActive(true); } m_iconsCurrencies.Clear(); for (int i = 0; i < EthereumController.CURRENCY_CODE.Length; i++) { m_iconsCurrencies.Add(EthereumController.CURRENCY_CODE[i], m_container.Find("IconsCurrency/" + EthereumController.CURRENCY_CODE[i])); } UpdateCurrency(); EthereumEventController.Instance.EthereumEvent += new EthereumEventHandler(OnEthereumEvent); }
// ------------------------------------------- /* * Constructor */ public void Initialize(params object[] _list) { ItemMultiObjectEntry item = (ItemMultiObjectEntry)_list[0]; m_container = this.gameObject.transform; m_id = (string)item.Objects[0]; m_date = (DateTimeOffset)item.Objects[2]; m_amount = (decimal)item.Objects[3]; m_fee = (decimal)item.Objects[4]; m_title = (string)item.Objects[5]; List <ItemMultiTextEntry> transactionScriptPubKey = (List <ItemMultiTextEntry>)item.Objects[6]; string addresses = ""; for (int i = 0; i < transactionScriptPubKey.Count; i++) { ItemMultiTextEntry sitem = transactionScriptPubKey[i]; if (addresses.Length > 0) { addresses += ":"; } addresses += sitem.Items[1]; } m_container.Find("Target").GetComponent <Text>().text = BitCoinController.Instance.AddressToLabel(addresses.Split(':')); m_container.Find("Title").GetComponent <Text>().text = m_title; string dateTrimmed = m_date.ToString(); if (dateTrimmed.Length > 0) { dateTrimmed = dateTrimmed.Substring(0, dateTrimmed.IndexOf('+')); } m_container.Find("Date").GetComponent <Text>().text = dateTrimmed; m_container.Find("Bitcoins").GetComponent <Text>().text = m_amount.ToString(); if (m_amount < 0) { m_container.GetComponent <Image>().color = new Color(188f / 255f, 83f / 255f, 141f / 255f); m_container.Find("IconsCalendar/Input").gameObject.SetActive(false); m_container.Find("IconsCalendar/Output").gameObject.SetActive(true); m_container.Find("IconsType/Sent").gameObject.SetActive(true); m_container.Find("IconsType/Received").gameObject.SetActive(false); } else { m_container.GetComponent <Image>().color = new Color(53f / 255f, 174f / 255f, 64f / 255f); m_container.Find("IconsCalendar/Input").gameObject.SetActive(true); m_container.Find("IconsCalendar/Output").gameObject.SetActive(false); m_container.Find("IconsType/Sent").gameObject.SetActive(false); m_container.Find("IconsType/Received").gameObject.SetActive(true); } m_iconsCurrencies.Clear(); for (int i = 0; i < BitCoinController.CURRENCY_CODE.Length; i++) { m_iconsCurrencies.Add(BitCoinController.CURRENCY_CODE[i], m_container.Find("IconsCurrency/" + BitCoinController.CURRENCY_CODE[i])); } UpdateCurrency(); BitcoinEventController.Instance.BitcoinEvent += new BitcoinEventHandler(OnBitcoinEvent); }