private GameState() { currencyState = new CurrencyState(); merchState = new MerchState(); concertState = new ConcertState(); equipmentState = new EquipmentState(); }
protected override void LoadData(MemoryStream ms) { IFormatter formatter = new BinaryFormatter(); GameState gd = (GameState)formatter.Deserialize(ms); this.currencyState = gd.currencyState == null ? new CurrencyState() : gd.currencyState; this.merchState = gd.merchState == null ? new MerchState() : gd.merchState; this.concertState = gd.concertState == null ? new ConcertState() : gd.concertState; this.equipmentState = gd.equipmentState == null ? new EquipmentState() : gd.equipmentState; this.currencyState.SynchronizeRealCurrencyAndScreenCurrency(); }
/// <summary> /// Will attempt to change this character's present EquipmentState to the specified state. /// Will not do anything if the state could not be changed. /// </summary> /// <param name="nextState">The state to try and change to. </param> /// <returns>TRUE if it was successful, else false.</returns> public bool ChangeState(EquipmentState nextState) { currentEquipmentState = nextState; return nextState == currentEquipmentState; }
public static bool SetPlayerEquipmentState(EquipmentState nextState) { if (player == null) { return false; } CharacterMotor motor = player.GetComponentInChildren<CharacterMotor>(); if (motor == null) { return false; } return motor.ChangeState(nextState); }
public void set_equip(EquipmentState s) { state_equip = s; }
public EquipmentData(EquipmentState state) { index = (int)state.equipmentIndex; charges = state.charges; chargeFinishTime = state.chargeFinishTime.t; }
// Update is called once per frame //控制设备的开启和关闭 void FixedUpdate() { EquipmentState es = equipment.GetComponent <ShowEquipState>().equipmentState; //让该设备上所有的货物都运动 List <GameObject> cargoList = new List <GameObject>(); FindExtension.FindGameObjectsWithTagRecursive(equipment, "Cargo", ref cargoList); //设备坏了,停止工作 if (es.facilityState == FacilityState.Error) { es.workState = State.Off; } //货物过渡 foreach (GameObject cargo in cargoList) { CargoMessage cm = cargo.GetComponent <ShowCargoInfo>().Cargomessage; if (EquipExtension.isCrossTrans(cargo, equipment))//到达过渡位置 { GameObject nextEquip = cm.EquipmentsQueue.ElementAt(2); EquipmentState nextEquipState = new EquipmentState();//有问题 List <GameObject> nextCargoList = new List <GameObject>(); FindExtension.FindGameObjectsWithTagRecursive(equipment, "Cargo", ref nextCargoList); //如果是最后一个传送带设备,关闭当前设备 if (nextEquip == null) { es.workState = State.Off; } else { nextEquipState = nextEquip.GetComponent <ShowEquipState>().equipmentState; } //货物下一个设备是最后一个顶升,这个顶升对它来说是独占设备 if (EquipExtension.isNextLastLiftTransfer(cargo)) { if (nextCargoList.Count > 0)//顶升上有货物 { es.workState = State.Off; } else { nextEquipState.isExcusive = Exclusive.Yes; } } //下一个设备开启 if (nextEquipState.workState == State.On) { if (nextEquipState.isExcusive == Exclusive.Yes)//如果是独占设备,本设备关闭 { es.workState = State.Off; } } //下一个设备关闭 if (nextEquipState.workState == State.Off) { if (nextCargoList.Count == 0)//下一个设备上没有货物,开启下一个设备 { nextEquipState.workState = State.On; } else //下一个设备有货物,关闭本设备 { es.workState = State.Off; } } } } //过渡思路 #region //if (货物到达设备关键点2)//准备过渡 //{ // 拿出下一个设备 // if (下一个设备不存在) // { // 设备=off // } // if(下一个设备On) // { // if (设备只能被单独占用(比如顶升)){ // 设备=off // } else { // 货物继续运动 // } // } // if (下一个设备off && 下一个设备的货物队列 == 0) // { // if (下一个设备 == Normal) // { // 下一个设备=on; // } // } // if(下一个设备off && 下一个设备货物队列 > 0) // { // 本设备=off; // } //} #endregion }
private void ProcessTransaction(object sender, ElapsedEventArgs e) { string status = EgateAPI.egGetOpStatus(current.Id, false).GetString(); if (status[0] == EgateAPI.StatusResult) { timer.Stop(); OnMessage(String.Format("Запрос обработан : {0}", status.Substring(1)), false); AuthResponse response = null; try { byte[] ba; string result = EgateAPI.egGetAuthResult(current.Id).GetString(out ba); if (IsValidResult(result)) { lastTransactionResult = (cancel == CancelState.Completed) ? TransactionResult.Cancelled : TransactionResult.OK; } else { lastTransactionResult = TransactionResult.Error; OnError(current); } response = AuthResponse.Parse(result, ba); } catch (Exception x) { OnMessage(x.Message, true); } finally { OnTransactionCompleted(lastTransactionResult, response); state = EquipmentState.CardTaken; OnStateChanged(state, status.Substring(1)); } } else if (status[0] == EgateAPI.StatusBusy) { EquipmentState s = state; switch (status[1]) { case EgateAPI.StatusWaitCard: //if (_state == EquipmentState.Started) s = EquipmentState.WaitingForCard; break; case EgateAPI.StatusCardEntered: //if (_state == EquipmentState.WaitingForCard) s = EquipmentState.CardInserted; break; case EgateAPI.StatusPinEntered: if (state == EquipmentState.CardInserted) { s = EquipmentState.PinEntered; } break; case EgateAPI.StatusAuthCompleted: if ((state != EquipmentState.Started) && (state != EquipmentState.WaitingForCard)) { s = EquipmentState.AuthCompleted; } break; default: s = state; break; } if (state == s) { return; } state = s; OnStateChanged(state, status.Substring(2)); } }
bool SetEquipmentInternal(On.RoR2.Inventory.orig_SetEquipmentInternal orig, RoR2.Inventory inventory, EquipmentState equipmentState, uint slot) { bool equipmentChanged = orig(inventory, equipmentState, slot); if (Data.modEnabled) { if (Data.mode == DataShop.mode) { if (inventoryLocal != null) { if (inventoryLocal == inventory) { int stageClearCountNew = Run.instance.stageClearCount; if (stageClearCountOld != stageClearCountNew) { stageClearCountOld = stageClearCountNew; equipmentFoundThisStage.Clear(); equipmentFoundThisStageTwice.Clear(); foreach (EquipmentState equipmentStateOlder in latestEquipment) { if (equipmentStateOlder.equipmentIndex != EquipmentIndex.None && !equipmentFoundThisStage.Contains(equipmentStateOlder.equipmentIndex)) { equipmentFoundThisStage.Add(equipmentStateOlder.equipmentIndex); } } } int slotAdjusted = (int)slot; if (slotAdjusted + 1 > latestEquipment.Count) { for (int appendIndex = 0; appendIndex < slotAdjusted + 1 - latestEquipment.Count; appendIndex++) { latestEquipment.Add(new EquipmentState(EquipmentIndex.None, new Run.FixedTimeStamp(), 0)); } } EquipmentState equipmentStateOld = latestEquipment[slotAdjusted]; if (!EquipmentState.Equals(equipmentStateOld, equipmentState)) { latestEquipment[slotAdjusted] = equipmentState; if (!equipmentFoundThisStage.Contains(latestEquipment[slotAdjusted].equipmentIndex)) { if (Data.allEquipmentIndexes.ContainsKey(equipmentState.equipmentIndex)) { if (DataShop.AddScrap(characterBody, Data.GetItemTier(Data.allEquipmentIndexes[equipmentState.equipmentIndex]))) { equipmentFoundThisStage.Add(equipmentState.equipmentIndex); } } } } } } } } return(equipmentChanged); }