public void addAction(string actionName) { ActionButton created = Instantiate(actionButtonPrefab, contents.transform); Action a = ActionStore.getActionByName(actionName, siroko); created.actionName.text = actionName; created.mp.text = a.cost.ToString(); created.wt.text = a.waitTime.ToString(); created.backgroundImage.color = getRarityColor(a.rarity); if (a.effectList.Exists(x => x.hasAttribute(Effect.Attribute.MAGIC))) { created.actionTypeImage.sprite = rod; } else { created.actionTypeImage.sprite = spear; } UnityAction <Button, string> addButtonClickEvent = (Button b, string str) => { b.onClick.AddListener(() => { timeline.tryAddAction(ActionStore.getActionByName(str, siroko)); }); }; addButtonClickEvent(created.button, actionName); created.messageArea = messageArea; actionbuttons.Add(created); }
///////////////////////////// PUBLIC METHODS //////////////////////////////////////////// void Awake() { var player = GameObject.FindGameObjectWithTag("Player"); m_PlayerActionStore = player.GetComponent <ActionStore>(); m_PlayerActionStore.actionStoreUpdated += UpdateIcon; }
public void addActionUnInteractable(string actionName) { if (!status) { status = FindObjectOfType <SirokoStats>(); } ActionButton created = Instantiate(actionButtonPrefab, contents.transform); Action a = ActionStore.getActionByName(actionName); created.actionName.text = actionName; created.backgroundImage.color = getRarityColor(a.rarity); created.mp.text = a.cost.ToString(); created.wt.text = ((int)(a.waitTime * BattleCharacter.getDefaultWaitTimeCutRate(status.getSpeedLevel()))).ToString(); if (a.effectList.Exists(x => x.hasAttribute(Effect.Attribute.MAGIC))) { created.actionTypeImage.sprite = rod; } else { created.actionTypeImage.sprite = spear; } created.messageArea = messageArea; actionbuttons.Add(created); }
public void init() { childDataInstances = new List <ListItem>(); foreach (string s in masterData) { string description = ""; switch (listType) { case ListType.ACTION: description = ActionStore.getActionByName(s).descriptionText; break; case ListType.ATTENDANT: description = "同行者さん!完全未定なので固定メッセージです"; break; case ListType.ENEMY: description = EnemyStore.getEnemyDescriptionByName(s); break; case ListType.EQUIP: description = EquipStore.getEquipByName(s).description; break; case ListType.ITEM: description = "アイテムでーす"; break; } addMaster(s, description); } }
//このフレームに積んであるアクションを実行 public void playActionCurrentFrame() { //プレイヤー行動 Action a = timeline.getActionByFrame(timeline.currentFrame); if (a != null && !player.isDead()) { consumeAction(a, ActorType.PLAYER); } //敵行動 List <EnemyAction> enemyActionList = timeline.getEnemyActionByFrame(timeline.currentFrame); foreach (EnemyAction ea in enemyActionList) { int enemyIndex = getEnemyIndexByHashCode(ea.actorHash); //死んでなかったらやる if (enemyIndex != -1 && !enemies[enemyIndex].isDead()) { consumeAction(ea, ActorType.ENEMY, enemyIndex); } else { Debug.LogFormat("{0}番目の敵は死んでるのでアクションを実行しませんでした", enemyIndex); } } if (timeline.currentFrame == timeline.framesPerTurn) { if (player.hasBuff(Buff.BuffID.ADDITIONAL_ENDATTACK)) { consumeAction(ActionStore.getActionByName("追幻起動"), ActorType.PLAYER); } } }
void Update() { if (_anim.GetCurrentAnimatorStateInfo(0).IsName("CristalContact")) { _heroDead = true; } else if (transform.position.y < -8f) { _heroDead = true; RestartHero(); } if (_heroDead) { _rgdBody.velocity = Vector2.zero; return; } ActionStore.ModifyColorFactor(0.0015f); _onTheGround = Physics2D.OverlapCircle(Groundpoint.position, _radius, LayerToTest); _anim.SetBool("onGround", _onTheGround); var horizontalMove = Input.GetAxis("Horizontal"); Debug.Log("Horizontal: " + horizontalMove); _rgdBody.velocity = new Vector2(horizontalMove * HeroSpeed, _rgdBody.velocity.y); ManageToJump(); _anim.SetFloat("speed", Mathf.Abs(horizontalMove)); SetHeroDirection(horizontalMove); }
public void GivenActionManagerContainsActionsWhenActionsAreSaveThenTheyAreAddedToTheDataModel() { Mock <IDsmModel> model = new Mock <IDsmModel>(); Mock <IActionManager> manager = new Mock <IActionManager>(); ActionStore store = new ActionStore(model.Object, manager.Object); Mock <IDsmElement> element1 = new Mock <IDsmElement>(); Mock <IDsmElement> element2 = new Mock <IDsmElement>(); List <IAction> managerActions = new List <IAction> { new ElementMoveUpAction(model.Object, element1.Object), new ElementMoveDownAction(model.Object, element2.Object) }; model.Setup(x => x.GetElementById(1)).Returns(element1.Object); model.Setup(x => x.GetElementById(2)).Returns(element2.Object); manager.Setup(x => x.GetActionsInChronologicalOrder()).Returns(managerActions); store.SaveToModel(); model.Verify(x => x.AddAction(It.IsAny <string>(), It.IsAny <IReadOnlyDictionary <string, string> >()), Times.Exactly(2)); model.Verify(x => x.AddAction(ElementMoveUpAction.TypeName, It.IsAny <IReadOnlyDictionary <string, string> >()), Times.Once()); model.Verify(x => x.AddAction(ElementMoveDownAction.TypeName, It.IsAny <IReadOnlyDictionary <string, string> >()), Times.Once()); }
// LIFECYCLE METHODS private void Awake() { GameObject player = GameObject.FindGameObjectWithTag("Player"); store = player.GetComponent <ActionStore>(); cooldownStore = player.GetComponent <CooldownStore>(); store.storeUpdated += UpdateIcon; }
// Start is called before the first frame update void Awake() { m_Mover = GetComponent <CharacterMovement>(); //m_Combat = GetComponent<CharacterCombat>(); m_Health = GetComponent <Health>(); m_Actions = GetComponent <ActionStore>(); m_Abilities = GetComponent <Abilities>(); }
//WTを現在の速度に応じたものに更新 public void updateActionWaitTime() { foreach (ActionButton button in actionbuttons) { int wt = ActionStore.getActionByName(button.actionName.text, siroko).waitTime; button.wt.text = wt.ToString(); } }
public void OnPointerEnter(PointerEventData eventData) { if (!messageArea) { messageArea = FindObjectOfType <MessageArea>(); } messageArea.updateText(ActionStore.getActionByName(actionName.text).descriptionText); }
public A MakeDecision(S state) { var player = _game.GetPlayer(state); var results = OrderActions(state, _game.GetActions(state), player, 0); _timer.Start(); _currDepthLimit = 0; do { IncrementDepthLimit(); if (_logEnabled) { } _heuristicEvaluationUsed = false; var newResults = new ActionStore <A>(); foreach (var action in results) { var value = MinValue(_game.GetResult(state, action), player, double.NegativeInfinity, double.PositiveInfinity, 1); if (!_timer.TimeOutOccurred()) { break; } newResults.Add(action, value); if (_logEnabled) { //TODO } } if (_logEnabled) { Console.WriteLine(); } if (newResults.Size() > 0) { results = newResults.Actions; if (!_timer.TimeOutOccurred()) { if (HasSafeWinner(newResults.UtilValues.ElementAt(0))) { break; } else if (newResults.Size() > 1 && IsSignificantlyBetter(newResults.UtilValues.ElementAt(0), newResults.UtilValues.ElementAt(1))) { break; } } } } while (!_timer.TimeOutOccurred() && _heuristicEvaluationUsed); return(results.ElementAt(0)); }
public static IMatsTelemetryClient CreateMats(IApplicationConfiguration applicationConfiguration, IPlatformProxy platformProxy, IMatsConfig matsConfig) { string dpti = platformProxy.GetDevicePlatformTelemetryId(); if (!IsDeviceEnabled(matsConfig.AudienceType, dpti)) { return(null); } string deviceNetworkState = platformProxy.GetDeviceNetworkState(); int osPlatformCode = platformProxy.GetMatsOsPlatformCode(); bool enableAggregation = true; IEventFilter eventFilter = new EventFilter(enableAggregation); var errorStore = new ErrorStore(); var scenarioStore = new ScenarioStore(TimeConstants.ScenarioTimeoutMilliseconds, errorStore); var allowedScopes = new HashSet <string>(); if (matsConfig.AllowedScopes != null) { foreach (string s in matsConfig.AllowedScopes) { allowedScopes.Add(s); } } var actionStore = new ActionStore( TimeConstants.ActionTimeoutMilliseconds, TimeConstants.AggregationWindowMilliseconds, errorStore, eventFilter, allowedScopes); var contextStore = ContextStore.CreateContextStore( matsConfig.AudienceType, applicationConfiguration.ClientName, applicationConfiguration.ClientVersion, dpti, deviceNetworkState, matsConfig.SessionId, osPlatformCode); IUploader uploader = new TelemetryUploader(matsConfig.DispatchAction, platformProxy, applicationConfiguration.ClientName); // it's this way in mats c++ bool isScenarioUploadDisabled = true; return(new MatsTelemetryClient( applicationConfiguration, platformProxy, errorStore, uploader, actionStore, scenarioStore, contextStore, isScenarioUploadDisabled)); }
private ActionTest(FaultAnalysisServiceMessageProcessor messageProcessor, ActionStore actionStore, IReliableStateManager stateManager, IReliableDictionary <string, string> internalTestsStarted) { ThrowIf.Null(internalTestsStarted, "internalTestsStarted"); this.actionStore = actionStore; this.stateManager = stateManager; this.internalTestsStarted = internalTestsStarted; this.mockClient = new MockClient(messageProcessor); }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuController.AddMenu(manageMenu); MenuController.EnableMenuToggleKeyOnController = false; MenuController.MenuToggleKey = (Control)0; //SubMenu MenuController.AddSubmenu(manageMenu, ManageMyWeapMenu.GetMenu()); //end manageMenu.OnItemSelect += (_menu, _item, _index) => { indexItem = _index; var myWp = GetConfig.PlayerWeapons.ElementAt(_index); var wpc = GetConfig.Config["Weapons"].FirstOrDefault(x => x["HashName"].ToString().Contains(myWp["name"].ToString())); ManageMyWeapMenu.GetMenu().MenuTitle = wpc["Name"].ToString(); //double totalPrice = double.Parse(GetConfig.Config["Weapons"][_index]["Price"].ToString()); //buyMenuConfirm.MenuTitle = GetConfig.Config["Weapons"][_index]["Name"].ToString(); //subMenuConfirmBuyBtnYes.Label = string.Format(GetConfig.Langs["MenuBuyWeaponsButtonYes"], totalPrice.ToString()); }; manageMenu.OnIndexChange += (_menu, _oldItem, _newItem, _oldIndex, _newIndex) => { indexItem = _newIndex; ActionStore.CreateObjectOnTable(_newIndex, "Manage", ActionStore.ObjectStore); }; manageMenu.OnMenuOpen += (_menu) => { foreach (var weapon in GetConfig.PlayerWeapons) { var wp = GetConfig.Config["Weapons"].FirstOrDefault(x => x["HashName"].ToString().Contains(weapon["name"].ToString())); MenuItem _weaponToManage = new MenuItem(wp["Name"].ToString(), "") { LeftIcon = MenuItem.Icon.ARROW_RIGHT }; manageMenu.AddMenuItem(_weaponToManage); MenuController.BindMenuItem(manageMenu, ManageMyWeapMenu.GetMenu(), _weaponToManage); } //ActionStore.CreateObjectOnTable(_menu.CurrentIndex, "Manage", ActionStore.ObjectStore); }; manageMenu.OnMenuClose += (_menu) => { manageMenu.ClearMenuItems(); }; }
/** * Template method controlling the search. It is based on iterative * deepening and tries to make to a good decision in limited time. Credit * goes to Behi Monsio who had the idea of ordering actions by utility in * subsequent depth-limited search runs. */ public virtual A makeDecision(S state) { metrics = new Metrics(); IStringBuilder logText = null; P player = game.GetPlayer(state); ICollection <A> results = orderActions(state, game.GetActions(state), player, 0); timer.start(); currDepthLimit = 0; do { incrementDepthLimit(); if (logEnabled) { logText = TextFactory.CreateStringBuilder("depth " + currDepthLimit + ": "); } heuristicEvaluationUsed = false; ActionStore newResults = new ActionStore(); foreach (A action in results) { double value = minValue(game.GetResult(state, action), player, double.NegativeInfinity, double.PositiveInfinity, 1); if (timer.timeOutOccurred()) { break; // exit from action loop } newResults.add(action, value); if (logEnabled) { logText.Append(action).Append("->").Append(value).Append(" "); } } if (logEnabled) { System.Console.WriteLine(logText); } if (newResults.size() > 0) { results = newResults.actions; if (!timer.timeOutOccurred()) { if (hasSafeWinner(newResults.utilValues.Get(0))) { break; // exit from iterative deepening loop } else if (newResults.size() > 1 && isSignificantlyBetter(newResults.utilValues.Get(0), newResults.utilValues.Get(1))) { break; // exit from iterative deepening loop } } } } while (!timer.timeOutOccurred() && heuristicEvaluationUsed); return(results.Get(0)); }
void addEnemyAction(BattleCharacter enemy) { string actionName = enemy.nextAction(); EnemyAction a = new EnemyAction(ActionStore.getActionByName(actionName, enemy)); a.actorHash = enemy.GetHashCode(); a.frame = Random.Range(5, timeline.framesPerTurn - 4); //0-4F目に置くと死ぬし最後の方に置くと見えなくなるのでその場しのぎ対策 a.predictedDamage = getPredictedDamage(enemy, player, a); a.isUpperSide = timeline.shouldBePlacedToUpperSide(a.frame); timeline.addEnemyAction(a, enemy); }
private void Awake() { _animator = GetComponent <Animator>(); _actionSlots = GetComponent <ActionStore>(); _playerInventory = GetComponent <Inventory>(); _chestInventory = GameObject.FindGameObjectWithTag("ChestCanvas"); _chestInventory.SetActive(false); UpdateCash(); UpdateRoach(); }
public override void setParameters(string itemName, int cost, StoreAreaComponent.ItemKind kind) { Action a = ActionStore.getActionByName(itemName); actionButton.actionName.text = itemName; actionButton.mp.text = a.cost.ToString(); actionButton.wt.text = a.waitTime.ToString(); actionButton.backgroundImage.color = getRarityColor(a.rarity); this.itemName = itemName; setCost(Action.getCostByRarity(a.rarity)); this.kind = kind; //TODO アイコン対応 どころかActionnButtonがじぶんでパラメータ設定したほうが良さそうだ }
public DsmApplication(IDsmModel dsmModel) { _dsmModel = dsmModel; _actionManager = new ActionManager(); _actionManager.ActionPerformed += OnActionPerformed; _actionStore = new ActionStore(_dsmModel, _actionManager); _queries = new DsmQueries(dsmModel); _metrics = new DsmMetrics(dsmModel); }
public bool canPutAction(string actionName) { Action a = ActionStore.getActionByName(actionName, siroko); if (a.waitTime > timeline.getRemainingFrames()) { return(false); } if (siroko.mp < a.cost) { return(false); } return(true); }
public void turnEnd() { currentGameState = GameState.TURN_PROCEEDING; messageArea.updateText(""); if (player.hasBuff(Buff.BuffID.ADDITIONAL_ATTACK)) { consumeAction(ActionStore.getActionByName("幻閃起動"), ActorType.PLAYER); } if (player.hasBuff(Buff.BuffID.ADDITIONAL_MAGIC)) { consumeAction(ActionStore.getActionByName("鏡射起動"), ActorType.PLAYER); } setGlovalInteractiveState(false); }
public UIStateTracker(IDisplayCombatState combatStateHandler) { _combatStateHandler = combatStateHandler; var playerCharacterIds = _combatStateHandler.GetPlayerCharacterIds(); ActiveCharacterId = _combatStateHandler.GetNextActivePlayerId(); _characterDefaults = new Dictionary <int, PlayerCharacterDefaults>(); foreach (var characterId in playerCharacterIds) { _characterDefaults.Add(characterId, new PlayerCharacterDefaults()); } ActiveAction = new ActionStore { TargetPositions = new List <int>() }; ActionPanelList = new List <IDisplayAction>(); }
private static void SetupMenu() { if (setupDone) { return; } setupDone = true; MenuController.AddMenu(mainMenu); MenuController.EnableMenuToggleKeyOnController = false; MenuController.MenuToggleKey = (Control)0; //Weapons Buy Menu MenuController.AddSubmenu(mainMenu, BuyMenu.GetMenu()); MenuItem subMenuBuyBtn = new MenuItem(GetConfig.Langs["MenuMainButtonBuyWeapons"], " ") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(subMenuBuyBtn); MenuController.BindMenuItem(mainMenu, BuyMenu.GetMenu(), subMenuBuyBtn); //Weapons Manage Menu MenuController.AddSubmenu(mainMenu, ManageWeaponsMenu.GetMenu()); MenuItem subMenuManageBtn = new MenuItem(GetConfig.Langs["MenuMainButtonManageWeapon"], " ") { RightIcon = MenuItem.Icon.ARROW_RIGHT }; mainMenu.AddMenuItem(subMenuManageBtn); MenuController.BindMenuItem(mainMenu, ManageWeaponsMenu.GetMenu(), subMenuManageBtn); mainMenu.OnMenuOpen += (_menu) => { GetConfig.ForceLoadWeapons(); }; mainMenu.OnMenuClose += (_menu) => { ActionStore.ExitBuyStore(); }; }
public void GivenDataModelContainsActionsWhenActionsAreLoadedThenTheyAreAddedToTheActionManager() { Mock <IDsmModel> model = new Mock <IDsmModel>(); Mock <IActionManager> manager = new Mock <IActionManager>(); ActionStore store = new ActionStore(model.Object, manager.Object); Dictionary <string, string> data1 = new Dictionary <string, string> { ["element"] = "1" }; Dictionary <string, string> data2 = new Dictionary <string, string> { ["element"] = "2" }; Mock <IDsmAction> action1 = new Mock <IDsmAction>(); action1.Setup(x => x.Type).Returns(ElementMoveUpAction.TypeName); action1.Setup(x => x.Data).Returns(data1); Mock <IDsmAction> action2 = new Mock <IDsmAction>(); action2.Setup(x => x.Type).Returns(ElementMoveDownAction.TypeName); action2.Setup(x => x.Data).Returns(data2); List <IDsmAction> actions = new List <IDsmAction> { action1.Object, action2.Object }; model.Setup(x => x.GetActions()).Returns(actions); Mock <IDsmElement> element1 = new Mock <IDsmElement>(); Mock <IDsmElement> element2 = new Mock <IDsmElement>(); model.Setup(x => x.GetElementById(1)).Returns(element1.Object); model.Setup(x => x.GetElementById(2)).Returns(element2.Object); store.LoadFromModel(); manager.Verify(x => x.Add(It.IsAny <ElementMoveDownAction>()), Times.Once()); manager.Verify(x => x.Add(It.IsAny <ElementMoveUpAction>()), Times.Once()); }
private void Awake() { //find the player var player = GameObject.FindGameObjectWithTag("Player"); if (!player) { return; } //find the action store _store = player.GetComponent <ActionStore>(); if (!_store) { return; } _store.storeUpdated += UpdateIcon; //setup the Hotkey number above the slot. _textObject.text = string.Format("{0}", _index + 1); }
public static ITelemetryClient CreateMats( IApplicationConfiguration applicationConfiguration, IPlatformProxy platformProxy, ITelemetryConfig telemetryConfig) { string dpti = platformProxy.GetDevicePlatformTelemetryId(); if (!IsDeviceEnabled(telemetryConfig.AudienceType, dpti)) { return(null); } string deviceNetworkState = platformProxy.GetDeviceNetworkState(); int osPlatformCode = platformProxy.GetMatsOsPlatformCode(); bool enableAggregation = true; IEventFilter eventFilter = new EventFilter(enableAggregation); var errorStore = new ErrorStore(); var scenarioStore = new ScenarioStore(TimeConstants.ScenarioTimeoutMilliseconds, errorStore); var allowedScopes = new HashSet <string>(); // TODO: need to determine what MATS was doing with the AllowedScopes and DeniedScopes values in the C++ impl // and possibly expose this value in the ITelemetryConfig interface. //if (telemetryConfig.AllowedScopes != null) //{ // foreach (string s in telemetryConfig.AllowedScopes) // { // allowedScopes.Add(s); // } //} var actionStore = new ActionStore( TimeConstants.ActionTimeoutMilliseconds, TimeConstants.AggregationWindowMilliseconds, errorStore, eventFilter, allowedScopes); var contextStore = ContextStore.CreateContextStore( telemetryConfig.AudienceType, applicationConfiguration.ClientName, applicationConfiguration.ClientVersion, dpti, deviceNetworkState, telemetryConfig.SessionId, osPlatformCode); IUploader uploader = new TelemetryUploader(telemetryConfig.DispatchAction, platformProxy, applicationConfiguration.ClientName); // it's this way in mats c++ bool isScenarioUploadDisabled = true; return(new TelemetryClient( applicationConfiguration, platformProxy, errorStore, uploader, actionStore, scenarioStore, contextStore, isScenarioUploadDisabled)); }
// LIFECYCLE METHODS private void Awake() { store = GameObject.FindGameObjectWithTag("Player").GetComponent <ActionStore>(); store.storeUpdated += UpdateIcon; }
public ActionStoreTests() { store = new ActionStore(@".\Actions"); }
public static async Task <ActionTest> CreateAsync(FaultAnalysisServiceMessageProcessor messageProcessor, ActionStore actionStore, IReliableStateManager stateManager) { ThrowIf.Null(messageProcessor, "messageProcessor"); ThrowIf.Null(actionStore, "actionStore"); ThrowIf.Null(stateManager, "stateManager"); IReliableDictionary <string, string> internalTestsStarted = await stateManager.GetOrAddAsync <IReliableDictionary <string, string> >("internalTests"); return(new ActionTest(messageProcessor, actionStore, stateManager, internalTestsStarted)); }
private void Awake() { health = this.GetComponent <Health>(); actionStore = GetComponent <ActionStore>(); }