public NpcShip(ContentManager content, string texture, int x, int y) : base(content, texture, x, y) { this.time = 0; this.handler = new MoveAction(this.MoveRight); this.IsInCombat = false; }
private void moveBackwardRadio_CheckedChanged(object sender, EventArgs e) { if (moveBackwardRadio.Checked) { move = MoveAction.Backward; } }
public Change GetNext(MoveAction action) { #if DEBUG if (lastIndex == (changes.Length - 1)) throw new InvalidOperationException(); #endif lastIndex++; this.changes[lastIndex].Action = action; return this.changes[lastIndex]; }
public NpcShip(ContentManager content, string texture, int x, int y, int width, int height) : base(content, texture, x, y) { this.time = 0; this.handler = new MoveAction(this.MoveRight); this.IsInCombat = false; this.rectangle = new Rectangle(x,y,width,height); this.Hull = Hull.Steel; this.Weapons = Weapons.Shredder; this.speed = 4; }
// Animate the shadow if queueing a move command for friendly characters public override void QueueMoveAction(int targetX, int targetY) { var path = CombatBoardManager.Instance.GetTilesInPath(ShadowX, ShadowY, targetX, targetY, false); var moveAction = new MoveAction(path); ActionQueue.Add(moveAction); // Decrease currentAp CurrentAp -= path.Count * Constants.ApCostPerMove; // Move shadow MoveShadow(moveAction); // Update UI visuals for new action queued }
ActionState ProcessAction(MoveAction action) { var dst = this.Location + action.Direction; if (this.ActionTicksUsed == 1) { if (this.Environment.Contains(dst) == false) { SendFailReport(new MoveActionReport(this, action.Direction), "could not move (outside map)"); return ActionState.Fail; } // total ticks = number of livings on the destination tile + 1 this.ActionTotalTicks = this.Environment.GetContents(dst).OfType<LivingObject>().Count() + 1; } if (this.ActionTicksUsed < this.ActionTotalTicks) return ActionState.Ok; // drop the carried item if we no longer haul if (this.CarriedItem != null) { var moveOk = this.CarriedItem.MoveTo(this.Environment, this.Location); Debug.Assert(moveOk); if (!moveOk) Trace.TraceWarning("unable to drop carried item"); this.CarriedItem = null; } var ok = MoveDir(action.Direction); if (!ok) { SendFailReport(new MoveActionReport(this, action.Direction), "could not move (blocked?)"); return ActionState.Fail; } SendReport(new MoveActionReport(this, action.Direction)); return ActionState.Done; }
public override void SetAction(Action act) { base.SetAction(act); moveAction = (MoveAction)act; string tId = moveAction.targetId; if (tId != "player") { state.target = GameObject.Find(tId); } else if(!state.target.activeSelf) { state.target = enemyManager.SelectTarget(); } switch(moveAction.offsetType) { case Action.OffsetType.POSITION_ZERO: direction = new Vector3(0, 0, 0); break; case Action.OffsetType.AROUND_1: direction = new Vector3(0, 0, 1); direction = Quaternion.Euler(0, moveAction.angle, 0) * direction; direction *= moveAction.distance; break; case Action.OffsetType.AROUND_2: direction = (state.agent.transform.position - state.target.transform.position).normalized; direction = Quaternion.Euler(0, moveAction.angle, 0) * direction; direction *= moveAction.distance; break; } if (moveAction.inertia == false) state.agent.acceleration = 1000; else state.agent.acceleration = 50; state.agent.speed = moveAction.speed; state.agent.destination = state.target.transform.position + direction; }
public static void HandleDirection(Direction dir) { var ob = GameData.Data.FocusedObject; var target = ob.Environment.GetContents(ob.Location + dir).OfType<LivingObject>().FirstOrDefault(); GameAction action; if (target == null) { dir = ob.Environment.AdjustMoveDir(ob.Location, dir); if (dir == Direction.None) return; action = new MoveAction(dir); } else action = new AttackAction(target); action.GUID = new ActionGUID(ob.World.PlayerID, 0); ob.RequestAction(action); }
public override void HandleInput(InputEvent inputEvent) { if (inputEvent is MapTileClickedInput) { MapTileClickedInput mapTileClickedInput = inputEvent as MapTileClickedInput; MoveAction moveAction = m_CurrentlySelectedEntity.GetAction <MoveAction>(); if (m_Paths.ContainsKey(mapTileClickedInput.coordinate) && moveAction.CanExecute(player, m_CurrentlySelectedEntity, mapTileClickedInput.coordinate, null)) { PerformingActionStateData stateData = ScriptableObject.CreateInstance <PerformingActionStateData>(); stateData.action = moveAction; stateData.source = m_CurrentlySelectedEntity; stateData.targetCoordinate = mapTileClickedInput.coordinate; dispatcher.Dispatch <PerformingActionState>(stateData); } else if (mapTileClickedInput.mapTile.entities.Count > 0 && player.GetEntity(mapTileClickedInput.mapTile.entities[0].Id) != null) { SelectedStateData selectedStateData = ScriptableObject.CreateInstance <SelectedStateData>(); selectedStateData.coordinate = mapTileClickedInput.coordinate; dispatcher.Dispatch <SelectedState>(selectedStateData); } else { dispatcher.Dispatch <IdleState>(); } } if (inputEvent is CycleSelectionInput) { int currentIndex = player.entities.FindIndex(entity => entity.Id == CurrentlySelectedEntity.Id); Entity availableEntity = player.entities .GetRange(currentIndex + 1, player.entities.Count - currentIndex - 1) .Find(entity => entity.ActionPoints > 0); if (availableEntity != null) { Coordinate coordinate = mapController.GetPositionOfEntity(availableEntity.Id); SelectedStateData selectedStateData = ScriptableObject.CreateInstance <SelectedStateData>(); selectedStateData.coordinate = coordinate; dispatcher.Dispatch <SelectedState>(selectedStateData); } else { dispatcher.Dispatch <IdleState>(); } } if (inputEvent is ActionButtonClickedInput) { ActionButtonClickedInput actionButtonClickedInput = inputEvent as ActionButtonClickedInput; PerformingActionStateData stateData = ScriptableObject.CreateInstance <PerformingActionStateData>(); stateData.action = m_CurrentlySelectedEntity.GetAction(actionButtonClickedInput.actionType); stateData.source = m_CurrentlySelectedEntity; stateData.target = actionButtonClickedInput.target; dispatcher.Dispatch <PerformingActionState>(stateData); } }
public async Task <PathMinDisplayed> CreatePath(PathModel path) { int mapId = 0; List <string> zones = new List <string>(); string userId = User.Claims.First(c => c.Type == "UserID").Value; var user = await _userManager.FindByIdAsync(userId); TrajetDB trajetDB = new TrajetDB() { Name = path.Name, Type = (TypePath)path.Type, GroupLevelMax = path.GroupLevelMax, GroupLevelMin = path.GroupLevelMin, CaptureItem = path.CaptureItem, Fk_User = new Guid(userId), MaxPod = path.MaxPod, MonsterQuantityMin = path.MonsterQuantityMin, MonsterQuantityMax = path.MonsterQuantityMax, LeaderBank = path.LeaderBank, IsCapture = path.IsCapture, ListRessource = path.ListRessource, Key = Guid.NewGuid() }; foreach (var monstreLevel in path.MonsterLevel) { if (trajetDB.MonsterLevel == null) { trajetDB.MonsterLevel = new List <SpecificMonsterLevel>(); } trajetDB.MonsterLevel.Add(new SpecificMonsterLevel() { MonsterId = monstreLevel.MonsterId, MonsterLevelMax = monstreLevel.MonsterLevelmax, MonsterLevelMin = monstreLevel.MonsterLevelMin }); } foreach (var monstreQuantity in path.MonsterQuantity) { if (trajetDB.MonsterQuantity == null) { trajetDB.MonsterQuantity = new List <SpecificMonsterQuantity>(); } trajetDB.MonsterQuantity.Add(new SpecificMonsterQuantity() { MonsterId = monstreQuantity.MonsterId, MonsterQuantityMax = monstreQuantity.MonsterQuantityMax, MontserQuantityMin = monstreQuantity.MonsterQuantityMin }); } foreach (var monstreCapture in path.MonsterCapture) { if (trajetDB.MonsterCapture == null) { trajetDB.MonsterCapture = new List <CaptureMonsterQuantity>(); } trajetDB.MonsterCapture.Add(new CaptureMonsterQuantity() { MonsterId = monstreCapture.MonsterId, MonsterQuantity = monstreCapture.MonsterQuantity }); } /* actions du trajet */ trajetDB.PathAction = new List <PathAction>(); foreach (PathActionModel action in path.PathAction) { PathAction pathActionToCreate = new PathAction(); if (!ListBank.Contains(action.MapPos)) { MapDB map = Database.Maps.Find(o => o.Coordinate == ("[" + action.MapPos.Replace(';', ',') + "]")).First(); mapId = map.Key; if (!zones.Contains(map.AreaName)) { zones.Add(map.AreaName); } pathActionToCreate.MapId = mapId; foreach (MapActionModel item in action.Actions) { if (pathActionToCreate.Actions == null) { pathActionToCreate.Actions = new List <MapAction>(); } if (item.FightAction != null) { FightAction fightActionToCreate = new FightAction() { Order = item.Order, IsAlone = item.FightAction.IsAlone }; pathActionToCreate.Actions.Add(fightActionToCreate); } else if (item.GatherAction != null) { GatherAction GatherActionToCreate = new GatherAction() { Order = item.Order }; pathActionToCreate.Actions.Add(GatherActionToCreate); } else if (item.InteractionAction != null) { InteractionAction InteractionActionToCreate = new InteractionAction() { Order = item.Order, InteractiveIdObject = item.InteractionAction.InteractiveidObject, InteractiveIdResponse = item.InteractionAction.InteractiveIdResponse, ToBackBank = item.InteractionAction.ToBackBank, ToGoBank = item.InteractionAction.ToGoBank }; pathActionToCreate.Actions.Add(InteractionActionToCreate); } else if (item.moveAction != null) { MoveAction MoveActionToCreate = new MoveAction() { Order = item.Order, ToBackBank = item.moveAction.ToBackBank, ToGoBank = item.moveAction.ToGoBank, CellId = item.moveAction.Cellid }; if (item.moveAction.Direction != null) { foreach (string direc in item.moveAction.Direction) { if (MoveActionToCreate.Direction == null) { MoveActionToCreate.Direction = new List <MovementDirectionEnum>(); } MoveActionToCreate.Direction.Add((MovementDirectionEnum)System.Enum.Parse(typeof(MovementDirectionEnum), direc.ToUpper())); } } pathActionToCreate.Actions.Add(MoveActionToCreate); } else if (item.UseItemAction != null) { UseItemAction UseItemActionToCreate = new UseItemAction() { Order = item.Order, ItemId = item.UseItemAction.ItemId, ToBackBank = item.UseItemAction.ToBackBank, ToGoBank = item.UseItemAction.ToGoBank }; pathActionToCreate.Actions.Add(UseItemActionToCreate); } else if (item.ZaapAction != null) { int zaapDestination = Database.Maps.Find(o => o.Coordinate == ("[" + action.MapPos.Replace(';', ',') + "]")).First().Key; ZaapAction UseItemActionctionToCreate = new ZaapAction() { Order = item.Order, Destination = zaapDestination, ZaapId = item.ZaapAction.ZaapId, ToBackBank = item.ZaapAction.ToBackBank, ToGoBank = item.ZaapAction.ToGoBank }; pathActionToCreate.Actions.Add(UseItemActionctionToCreate); } else if (item.ZaapiAction != null) { int zaapiDestination = Database.Maps.Find(o => o.Coordinate == ("[" + action.MapPos.Replace(';', ',') + "]")).First().Key; ZaapAction UseItemActionctionToCreate = new ZaapAction() { Order = item.Order, Destination = zaapiDestination, ZaapId = item.ZaapiAction.ZaapiId, ToBackBank = item.ZaapiAction.ToBackBank, ToGoBank = item.ZaapiAction.ToGoBank }; pathActionToCreate.Actions.Add(UseItemActionctionToCreate); } } trajetDB.PathAction.Add(pathActionToCreate); } else { foreach (MapActionModel item in action.Actions) { pathActionToCreate = new PathAction(); if (item.moveAction != null) { mapId = item.moveAction.MapId.Value; pathActionToCreate.MapId = mapId; MoveAction MoveActionToCreate = new MoveAction() { Order = item.Order, ToBackBank = item.moveAction.ToBackBank, ToGoBank = item.moveAction.ToGoBank, CellId = item.moveAction.Cellid, MapId = mapId }; if (item.moveAction.Direction != null) { foreach (string direc in item.moveAction.Direction) { if (MoveActionToCreate.Direction == null) { MoveActionToCreate.Direction = new List <MovementDirectionEnum>(); } MoveActionToCreate.Direction.Add((MovementDirectionEnum)System.Enum.Parse(typeof(MovementDirectionEnum), direc.ToUpper())); } } if (trajetDB.PathAction.Exists(o => o.MapId == mapId)) { trajetDB.PathAction.Find(o => o.MapId == mapId).Actions.Add(MoveActionToCreate); } else { pathActionToCreate.Actions = new List <MapAction>(); pathActionToCreate.Actions.Add(MoveActionToCreate); trajetDB.PathAction.Add(pathActionToCreate); } } else if (item.BankAction != null) { mapId = item.BankAction.MapId.Value; pathActionToCreate.MapId = mapId; BankAction BankActionToCreate = new BankAction() { MapId = mapId, Order = item.Order }; if (trajetDB.PathAction.Exists(o => o.MapId == mapId)) { trajetDB.PathAction.Find(o => o.MapId == mapId).Actions.Add(BankActionToCreate); } else { pathActionToCreate.Actions = new List <MapAction>(); pathActionToCreate.Actions.Add(BankActionToCreate); trajetDB.PathAction.Add(pathActionToCreate); } } } } } trajetDB.Zones = zones; PathMinDisplayed retourPath = new PathMinDisplayed() { IsCapture = trajetDB.IsCapture, Key = trajetDB.Key, Name = trajetDB.Name, Type = trajetDB.Type, UsedNumber = 0, Zones = trajetDB.Zones }; await Database.Paths.InsertOneAsync(trajetDB); return(retourPath); }
// 上移動 public void MoveUp() { moveFlag = true; moveBeforePosition = transform.position; // 移動前の座標に現在の座標を入れる ChangeDirection(MoveDirection.UP); // カメラに対応した移動方向に変更 ChangeAngle(); // アリスの向きを変更 moveAction = MoveAction.NEXT; // アリスの行動を進めるに }
public void Move (string path, string newname, FileType type) { var action = new MoveAction(this, path, newname, type); if(action.Do()) _actionStack.Add(action); }
public void Move (string[] paths, string[] newnames, FileType[] types) { var action = new MoveAction(this, paths, newnames, types); if(action.Do()) _actionStack.Add(action); }
private void MoveButton_Click(object sender, RoutedEventArgs e) { var b = (Button)sender; var d = (Direction)Enum.Parse(typeof(Direction), (string)b.Tag); var action = new MoveAction(d); AddAction(action); }
protected override void Start() { base.Start(); RegisterWithTeam(); _modelRotControl.SetDesiredLookDirec(-Vector3.forward); agentActions = GetComponent<AgentActions>(); foreach (AgentActions.ActionData actionData in agentActions.proactiveActions) { if (actionData.action as MoveAction != null) { moveAction = actionData.action as MoveAction; } } }
public List <TileAction> getRoute(Tile spawn, List <Tile> Tiles, Grid grid) { MoveAction LeadAction = CheckDirection(spawn, grid); Tile currentTile = spawn; Random random = new Random(); int number; try { while (currentTile.Type != TileType.ExitPoint) { currentTile = GetNextTile(currentTile, LeadAction.direction, Tiles); if (currentTile.Type == TileType.ControlPoint) { Actions.Add(LeadAction); bool checkFront = false; bool checkLeft = false; bool checkRight = false; void TurnLeft() { currentTile = GetNextTile(currentTile, LeadAction.direction, Tiles); Actions.Add(LeadAction); currentTile = GetNextTile(currentTile, LeadAction.direction, Tiles); Actions.Add(LeadAction); if (LeadAction.direction == Direction.Up) { LeadAction = new MoveAction(Direction.Left); } else if (LeadAction.direction == Direction.Down) { LeadAction = new MoveAction(Direction.Right); } else if (LeadAction.direction == Direction.Right) { LeadAction = new MoveAction(Direction.Up); } else if (LeadAction.direction == Direction.Left) { LeadAction = new MoveAction(Direction.Down); } currentTile = GetNextTile(currentTile, LeadAction.direction, Tiles); Actions.Add(LeadAction); } void TurnRight() { currentTile = GetNextTile(currentTile, LeadAction.direction, Tiles); Actions.Add(LeadAction); if (LeadAction.direction == Direction.Up) { LeadAction = new MoveAction(Direction.Right); } else if (LeadAction.direction == Direction.Down) { LeadAction = new MoveAction(Direction.Left); } else if (LeadAction.direction == Direction.Right) { LeadAction = new MoveAction(Direction.Down); } else if (LeadAction.direction == Direction.Left) { LeadAction = new MoveAction(Direction.Up); } currentTile = GetNextTile(currentTile, LeadAction.direction, Tiles); Actions.Add(LeadAction); } if (LeadAction.direction == Direction.Up) { if (FindSpecificTile(0, -3, Tiles, currentTile).Type == TileType.Road) { checkFront = true; } if (FindSpecificTile(-2, -2, Tiles, currentTile).Type == TileType.Road) { checkLeft = true; } if (FindSpecificTile(1, -1, Tiles, currentTile).Type == TileType.Road) { checkRight = true; } if (checkFront && checkLeft && checkRight) // Car is in a plus intersection { number = random.Next(3); switch (number) { case 0: //going Left TurnLeft(); break; case 1: //going forward Actions.Add(LeadAction); break; case 2: //going right TurnRight(); break; } } else if (checkFront && checkLeft && !checkRight) // T-left intersection { number = random.Next(2); switch (number) { case 0: //going Left TurnLeft(); break; case 1: //going forward Actions.Add(LeadAction); break; } } else if (checkFront && !checkLeft && checkRight) // T-right intersection { number = random.Next(2); switch (number) { case 0: //going right TurnRight(); break; case 1: //going forward Actions.Add(LeadAction); break; } } else if (!checkFront && checkLeft && checkRight) // T-down intersection { number = random.Next(2); switch (number) { case 0: //going right TurnRight(); break; case 1: //going left TurnLeft(); break; } } else if (!checkFront && checkLeft && !checkRight) // Corner Left { TurnLeft(); } else if (!checkFront && !checkLeft && checkRight) // Corner Right { TurnRight(); } } else if (LeadAction.direction == Direction.Down) { if (FindSpecificTile(0, 3, Tiles, currentTile).Type == TileType.Road) { checkFront = true; } if (FindSpecificTile(2, 2, Tiles, currentTile).Type == TileType.Road) { checkLeft = true; } if (FindSpecificTile(-1, 1, Tiles, currentTile).Type == TileType.Road) { checkRight = true; } if (checkFront && checkLeft && checkRight) // Car is in a plus intersection { number = random.Next(3); switch (number) { case 0: //going Left TurnLeft(); break; case 1: //going forward Actions.Add(LeadAction); break; case 2: //going right TurnRight(); break; } } else if (checkFront && !checkLeft && checkRight) // T-left intersection { number = random.Next(2); switch (number) { case 0: //going Left TurnRight(); break; case 1: //going forward Actions.Add(LeadAction); break; } } else if (checkFront && checkLeft && !checkRight) // T-right intersection { number = random.Next(2); switch (number) { case 0: //going right TurnLeft(); break; case 1: //going forward Actions.Add(LeadAction); break; } } else if (!checkFront && checkLeft && checkRight) // T-up intersection { number = random.Next(2); switch (number) { case 0: //going right TurnRight(); break; case 1: //going left TurnLeft(); break; } } else if (!checkFront && checkLeft && !checkRight) // Corner Right { TurnLeft(); } else if (!checkFront && !checkLeft && checkRight) // Corner Left { TurnRight(); } } else if (LeadAction.direction == Direction.Left) { if (FindSpecificTile(-3, 0, Tiles, currentTile).Type == TileType.Road) // Checking front { checkFront = true; } if (FindSpecificTile(-2, 2, Tiles, currentTile).Type == TileType.Road) // Checking left { checkLeft = true; } if (FindSpecificTile(-1, -1, Tiles, currentTile).Type == TileType.Road) // Checking right { checkRight = true; } if (checkFront && checkLeft && checkRight) // Car is in a plus intersection { number = random.Next(3); switch (number) { case 0: //going Left TurnLeft(); break; case 1: //going forward Actions.Add(LeadAction); break; case 2: //going right TurnRight(); break; } } // Plus intersection else if (!checkFront && checkLeft && checkRight) // T-right intersection { number = random.Next(2); switch (number) { case 0: //going Left TurnLeft(); break; case 1: //going right TurnRight(); break; } } // T-Left else if (checkFront && checkLeft && !checkRight) // T-down intersection { number = random.Next(2); switch (number) { case 0: //going Left TurnLeft(); break; case 1: //going right Actions.Add(LeadAction); break; } } else if (checkFront && !checkLeft && checkRight) // T-up intersection { number = random.Next(2); switch (number) { case 0: //going Left TurnRight(); break; case 1: //going forward Actions.Add(LeadAction); break; } } else if (!checkFront && checkLeft && !checkRight) // Corner Left { TurnLeft(); } else if (!checkFront && !checkLeft && checkRight) { TurnRight(); } } else if (LeadAction.direction == Direction.Right) { if (FindSpecificTile(3, 0, Tiles, currentTile).Type == TileType.Road) { checkFront = true; } if (FindSpecificTile(2, -2, Tiles, currentTile).Type == TileType.Road) { checkLeft = true; } if (FindSpecificTile(1, 1, Tiles, currentTile).Type == TileType.Road) { checkRight = true; } if (checkFront && checkLeft && checkRight) // Car is in a plus intersection { number = random.Next(3); switch (number) { case 0: //going Left TurnLeft(); break; case 1: //going forward Actions.Add(LeadAction); break; case 2: //going right TurnRight(); break; } } else if (!checkFront && checkLeft && checkRight) // T-left intersection { number = random.Next(2); switch (number) { case 0: //going Left TurnRight(); break; case 1: //going forward TurnLeft(); break; } } else if (checkFront && checkLeft && !checkRight) // T-up intersection { number = random.Next(2); switch (number) { case 0: //going right TurnLeft(); break; case 1: //going forward Actions.Add(LeadAction); break; } } else if (checkFront && !checkLeft && checkRight) // T-Down intersection { number = random.Next(2); switch (number) { case 0: //going forward Actions.Add(LeadAction); break; case 1: //going left TurnRight(); break; } } else if (!checkFront && checkLeft && !checkRight) // Corner Right { TurnLeft(); } else if (!checkFront && !checkLeft && checkRight) // Corner Left { TurnRight(); } } } else { Actions.Add(LeadAction); } } } catch (NullReferenceException ex) { Console.WriteLine("Something happened"); } return(Actions); }
public void OnEnable() { _target = target as MoveAction; }
private void Start() { player = GameObject.FindGameObjectWithTag(Tags.Player).GetComponent <UserSoldier>(); gameManager = GameObject.FindGameObjectWithTag(Tags.GameController).GetComponent <GameManager>(); npc = GetComponent <NPCSoldier>(); npc.Damaged += Damaged; nextRadius = gameManager.nextRadius; SetCoverPos(transform.position); var notInSafeZoneCond = new ConditionNode(IsInSafeZone, false); var haveEnemyCond = new ConditionNode(HaveEnemyInSight, true); var beingShootCond = new ConditionNode(BeingShoot, true); var haveWeaponCond = new ConditionNode(HaveWeapon, true); var seekWeaponCond = new ConditionNode(SeekWeapon, true); var equipAction = new SetEquipmentAction(npc, true); var notEquipAction = new SetEquipmentAction(npc, false); var crouchAction = new SetCrouchAction(npc, true); var notCrouchAction = new SetCrouchAction(npc, false); var toSafeZoneAction = new MoveAction(npc, blackBoard, safeZoneKey); var goCoverAction = new MoveAction(npc, blackBoard, coverPosKey); var FallBackAction = new MoveAction(npc, blackBoard, fallBackPosKey); var goWeaponAction = new MoveAction(npc, blackBoard, weaponPosKey); var pickUpWeaponAction = new PickUpWeaponAction(npc, blackBoard, weaponKey); var shootAction = new ShootAction(npc, blackBoard, enemyPosKey); var turnToShooterAction = new TurnAction(npc, blackBoard, shooterPosKey); var idleAction = new IdleAction(npc); var combat = new SequenceNode(); combat.AddCondition(haveWeaponCond); combat.AddNode(equipAction); combat.AddNode(shootAction); var fallBack = new SequenceNode(); fallBack.AddNode(FallBackAction); haveEnemy = new SelectionNode(); haveEnemy.AddCondition(haveEnemyCond); haveEnemy.AddNode(combat); haveEnemy.AddNode(fallBack); var counter = new SequenceNode(); counter.AddCondition(haveWeaponCond); counter.AddNode(turnToShooterAction); beingShoot = new SelectionNode(); beingShoot.AddCondition(beingShootCond); beingShoot.AddNode(counter); beingShoot.AddNode(fallBack); toSafeZone = new SequenceNode(); toSafeZone.AddCondition(notInSafeZoneCond); toSafeZone.AddNode(notCrouchAction); toSafeZone.AddNode(notEquipAction); toSafeZone.AddNode(toSafeZoneAction); stayInCover = new SequenceNode(); stayInCover.AddCondition(haveWeaponCond); stayInCover.AddNode(goCoverAction); stayInCover.AddNode(crouchAction); stayInCover.AddNode(idleAction); seekWeapon = new SequenceNode(); seekWeapon.AddCondition(seekWeaponCond); seekWeapon.AddNode(goWeaponAction); seekWeapon.AddNode(pickUpWeaponAction); idle = new SelectionNode(); idle.AddNode(stayInCover); idle.AddNode(seekWeapon); root.AddNode(haveEnemy); root.AddNode(beingShoot); root.AddNode(toSafeZone); root.AddNode(idle); }
public override void Execute() { var state = BattleViewModel.State; if (state == BattleUIState.Uninitialized || state == BattleUIState.PhaseChanging || state == BattleUIState.Preparations || state == BattleUIState.Surveying) { return; } var combatant = BattleViewModel.Map.GetAtPosition(Position); if (state == BattleUIState.SelectingUnit) { if (combatant != null && combatant.Army == ArmyType.Friendly) { var actions = AvailableActions.GetAvailableActionTypes(combatant); if (actions.Count <= 0) { return; } // Mark the unit at Position as selected, change the battle state. BattleViewModel.SelectedCombatant = combatant; BattleViewModel.State = BattleUIState.SelectingAction; BattleViewModel.AvailableActions = actions; var dimensions = BattleViewModel.Dimensions; var worldPosition = dimensions.GetWorldPositionForGridPosition(combatant.Position); UnitSelectedSignal.Dispatch(worldPosition); } } else if (state == BattleUIState.SelectingMoveLocation) { var map = BattleViewModel.Map; var path = BattleViewModel.CurrentMovementPath; if (path != null) { // Don't allow movement to the terminal points of a path if they are blocked. var terminus = path.Terminus; if (!map.IsBlocked(terminus)) { var positions = path.Positions.GetRange(1, path.Positions.Count - 1); var action = new MoveAction(map, path.Combatant, positions.Last(), positions); AnimateActionSignal.Dispatch(action); BattleViewModel.State = BattleUIState.CombatantMoving; } } } else if (state == BattleUIState.SelectingInteractTarget) { var map = BattleViewModel.Map; var tile = map.GetEventTile(Position); // Only if the player clicks on a tile that is actually interactible by clicks if (tile != null && tile.InteractionMode == InteractionMode.Use) { EventTileInteractedSignal.Dispatch(tile); } } else if (state == BattleUIState.SelectingAttackTarget) { if (combatant != null && combatant.Army == ArmyType.Enemy) { // Forecast the fight against this unit var attacker = BattleViewModel.SelectedCombatant; var battle = BattleViewModel.Battle; var selectedUnitPosition = attacker.Position; var distanceToTarget = MathUtils.ManhattanDistance(selectedUnitPosition, Position); var map = BattleViewModel.Map; SkillType skill; if (BattleViewModel.SpecialAttack) { if (!attacker.SpecialSkill.HasValue) { throw new ArgumentException("Combatant " + attacker.Id + " has no special skill configured."); } skill = attacker.SpecialSkill.Value; } else { skill = battle.GetWeaponSkillForRange(attacker, distanceToTarget); } var skillDatabase = new SkillDatabase(map); var forecaster = new FightForecaster(map, skillDatabase); var fight = forecaster.Forecast(BattleViewModel.SelectedCombatant, combatant, skill); FightForecastSignal.Dispatch(fight); BattleViewModel.FightForecast = fight; BattleViewModel.State = BattleUIState.ForecastingCombat; } } }
protected void ChangeIndex(MoveAction moveAction, int Index, object item) { var currentItem = item as IIndexable; if (currentItem == null) { return; } switch (moveAction) { case MoveAction.Top: IIndexable topItem = GetItem(0); int topIndex = topItem.Index; List <int> tempArray = new List <int>(); foreach (var tempItem in InnerList) { tempArray.Add((tempItem as IIndexable).Index); } for (int i = 0; i < Index; i++) { IIndexable moveitem = InnerList[i] as IIndexable; moveitem.Index = tempArray[i + 1]; } currentItem.Index = topIndex; break; case MoveAction.Up: if (Index == 0) { return; } IIndexable prevItem = GetItem(Index - 1); int prevIndex = prevItem.Index; prevItem.Index = currentItem.Index; currentItem.Index = prevIndex; break; case MoveAction.Down: IIndexable nextItem = GetItem(Index + 1); int nextIndex = nextItem.Index; nextItem.Index = currentItem.Index; currentItem.Index = nextIndex; break; case MoveAction.Bottom: IIndexable bottomItem = GetItem(InnerList.Count - 1); int bottomIndex = bottomItem.Index; for (int i = InnerList.Count - 1; i > Index; i--) { IIndexable moveitem = InnerList[i] as IIndexable; moveitem.Index = (InnerList[i - 1] as IIndexable).Index; } currentItem.Index = bottomIndex; break; default: break; } RefreshDefaultView(); if (TargetElement != null) { TargetElement.SelectedItem = null; } }
//Function called externally from the buttons on the action panel. Tells the combat manager to hilight an action's range public void SelectActionAtIndex(int actionIndex_) { //Clearing all tile highlights before we highlight different ones CombatManager.globalReference.ClearCombatTileHighlights(); //Getting a reference to the character that's currently acting Character actingCharacter = CombatManager.globalReference.actingCharacters[0]; //Finding out which tile the acting character is on CombatTile actingCharsTile = CombatManager.globalReference.FindCharactersTile(actingCharacter); //If the currently selected action is a move action, we need to clear tile highlights along its movement path if (this.selectedAction != null && this.selectedAction.GetComponent <MoveAction>()) { this.selectedAction.GetComponent <MoveAction>().ClearMovePathHighlights(); } //Destroying the game object that holds the currently selected action if (this.selectedAction != null) { Destroy(this.selectedAction.gameObject); } //Creating an instance of the newly selected action prefab object GameObject actionObj = null; //Finding the range of the action based on the button hit int actionRange = 0; switch (this.actionTypeShown) { case Action.ActionType.Major: actionRange = actingCharacter.charActionList.majorActions[actionIndex_].range; actionObj = GameObject.Instantiate(actingCharacter.charActionList.majorActions[actionIndex_].gameObject); //this.selectedAction = actingCharacter.charActionList.standardActions[actionIndex_]; break; case Action.ActionType.Minor: actionRange = actingCharacter.charActionList.minorActions[actionIndex_].range; actionObj = GameObject.Instantiate(actingCharacter.charActionList.minorActions[actionIndex_].gameObject); break; case Action.ActionType.Fast: actionRange = actingCharacter.charActionList.fastActions[actionIndex_].range; actionObj = GameObject.Instantiate(actingCharacter.charActionList.fastActions[actionIndex_].gameObject); break; case Action.ActionType.Massive: actionRange = actingCharacter.charActionList.massiveActions[actionIndex_].range; actionObj = GameObject.Instantiate(actingCharacter.charActionList.massiveActions[actionIndex_].gameObject); break; } //Getting the action component reference from the created action object this.selectedAction = actionObj.GetComponent <Action>(); //Finding out which tiles need to be hilighted if this action isn't a move action List <CombatTile> tilesToHighlight; List <CombatTile> tilesToCheckForCharacters = new List <CombatTile>(); if (!this.selectedAction.GetComponent <MoveAction>()) { tilesToHighlight = PathfindingAlgorithms.FindTilesInActionRange(actingCharsTile, actionRange); tilesToCheckForCharacters = tilesToHighlight; } //If this action is a move action, we have to find the selected tiles based on environment obstacles else { MoveAction ourMoveAct = this.selectedAction.GetComponent <MoveAction>(); //Looping through all of the acting character's perks to see if there are any movement boost perks int rangeModifier = 0; foreach (Perk charPerk in actingCharacter.charPerks.allPerks) { //If the current perk is a movement boost perk that applies to this movement's action type, we apply the number of added spaces if (charPerk.GetType() == typeof(MovementBoostPerk) && ourMoveAct.type == charPerk.GetComponent <MovementBoostPerk>().actionTypeToBoost) { rangeModifier += charPerk.GetComponent <MovementBoostPerk>().addedMovementSpaces; } } //Highlighting all tiles in range tilesToHighlight = PathfindingAlgorithms.FindTilesInActionRange(actingCharsTile, actionRange + rangeModifier, ourMoveAct.ignoreObstacles); tilesToCheckForCharacters = PathfindingAlgorithms.FindTilesInActionRange(actingCharsTile, actionRange + rangeModifier + 1); } //Looping through all tiles in range and hilighting them foreach (CombatTile tile in tilesToHighlight) { tile.inActionRange = true; tile.HighlightTile(false); } //Looping through all of the tiles around the action highlights to check for characters foreach (CombatTile checkedTile in tilesToCheckForCharacters) { //If there's a character sprite on this tile, we hide it a bit if (checkedTile.objectOnThisTile != null) { if (checkedTile.objectOnThisTile.GetComponent <Character>()) { //Getting the sprite base for the character CharacterSpriteBase cSprite = CombatManager.globalReference.GetCharacterSprite(checkedTile.objectOnThisTile.GetComponent <Character>()); //If the character on the tile isn't the one that's acting if (cSprite.ourCharacter != CombatManager.globalReference.actingCharacters[0]) { cSprite.MakeSpritesTransparent(); } } } } //Displays the action's details this.UpdateActionDetailsPanel(); }
/// <summary> /// Moves child elements based on the reference element and move action. /// </summary> /// <param name="referenceElement">element for which moved items will be above or below it</param> private static bool TryMoveElements(ReadOnlyCollection <ProjectItemElement> elements, ProjectItemElement referenceElement, MoveAction moveAction) { var parent = referenceElement.Parent; if (parent == null || !elements.Any()) { return(false); } // Sanity check var atLeastOneElementMoved = false; switch (moveAction) { case MoveAction.Up: foreach (var element in elements) { var elementParent = element.Parent; if (elementParent != null) { elementParent.RemoveChild(element); parent.InsertBeforeChild(element, referenceElement); atLeastOneElementMoved = true; } } break; case MoveAction.Down: // Iterate in reverse order when we are wanting to move elements down. // If we didn't do this, the end result would be the moved elements are reversed. for (var i = elements.Count - 1; i >= 0; --i) { var element = elements[i]; var elementParent = element.Parent; if (elementParent != null) { elementParent.RemoveChild(element); parent.InsertAfterChild(element, referenceElement); atLeastOneElementMoved = true; } } break; } return(atLeastOneElementMoved); }
/// <summary> /// Move project elements based on the given project tree and move action. /// </summary> private static Task <bool> TryMoveAsync(ConfiguredProject configuredProject, IProjectTree projectTree, IProjectTree referenceProjectTree, MoveAction moveAction) { return(ModifyProjectAsync(configuredProject, project => TryMove(project, projectTree, referenceProjectTree, moveAction))); }
public AI_Action(MoveAction move) { type = Type.Move; this.move = move; }
public abstract bool CanPerformAction(MoveAction action);
public void toggleBoat(BoatController boat) { MoveAction action = MoveAction.getAction(boat.getTarget(), boat.speed); this.addAction(boat.getBoat(), action, this); }
protected override GameAction PrepareNextActionOverride(out JobStatus progress) { var random = this.Worker.World.Random; int rand = random.Next(100); GameAction action = null; Direction dir = m_dir; if (rand < 25) { dir = Direction.None; } else if (rand < 50) { } else if (rand < 75) { var v = dir.ToIntVector3(); v = v.FastRotate(random.Next() % 2 == 0 ? 1 : -1); dir = v.ToDirection(); } else { var v = dir.ToIntVector3(); v = v.FastRotate(random.Next() % 2 == 0 ? 2 : -2); dir = v.ToDirection(); } if (dir == Direction.None) { action = new WaitAction(random.Next(4) + 1); } else { var env = this.Worker.Environment; m_dir = dir; IntVector2 ov = dir.ToIntVector2(); for (int i = 0; i < 7; ++i) { var v = ov.FastRotate(((i + 1) >> 1) * (((i % 2) << 1) - 1)); var d = env.AdjustMoveDir(this.Worker.Location, v.ToDirection()); if (d != Direction.None) action = new MoveAction(d); } if (action == null && this.Worker.CanMoveTo(Direction.Up)) action = new MoveAction(Direction.Up); if (action == null && this.Worker.CanMoveTo(Direction.Down)) action = new MoveAction(Direction.Down); if (action == null) action = new WaitAction(random.Next(4) + 1); } progress = JobStatus.Ok; return action; }
private void StartWalk() { aiStatus = AIStatus.walk; int coef = 60; if (Action is MoveAction) { coef = 30; } var shalgo = UnityEngine.Random.Range(0, 100) < coef; if (shalgo) { var randPos = new Vector3(bornPosition.x + UnityEngine.Random.Range(-isHomeDist, isHomeDist), bornPosition.y, bornPosition.z + UnityEngine.Random.Range(-isHomeDist, isHomeDist)); Action = new MoveAction(this, randPos, StartWalk); } else { Action = new StayAction(this, StartWalk); } }
public override bool condition() { return(MoveAction.getCondition(performer, target, controller)); }
// 巻き戻し public void MoveReturn() { if (saveCount > 0) { timeFlag = true; timeBackFlag = true; moveFlag = true; moveBeforePosition = transform.position; // 移動前の座標に現在の座標を入れる playerAngle = saveMovePlayerAngle[saveCount - 1]; // プレイヤーの向きに1つ前の向きを取得 moveDirection = saveMoveDirection[saveCount - 1]; // 移動方向に1つ前の移動方向を取得 // キー入力による移動の場合 if (saveMoveInput[saveCount - 1] == true) { moveCount--; ModeCheck(); ModeCountUp(); // 保存されている移動方向が switch(saveMoveDirection[saveCount - 1]) { case MoveDirection.FRONT: case MoveDirection.BACK: case MoveDirection.LEFT: case MoveDirection.RIGHT: ResetPosition(); moveBeforePosition = transform.position; SetAnimation(Motion.WALK_RETURN); ResetAnimation(Player.Motion.CLIMB1); ResetAnimation(Player.Motion.CLIMB2); break; case MoveDirection.STOP: SetAnimation(Motion.STAY_RETURN); break; } } // 移動方向が上下の場合はプレイヤーの向きを入れる if ((moveDirection == MoveDirection.UP) || (moveDirection == MoveDirection.DOWN)) { switch (playerAngle) { case PlayerAngle.FRONT: transform.localEulerAngles = angleFront; break; case PlayerAngle.BACK: transform.localEulerAngles = angleBack; break; case PlayerAngle.LEFT: transform.localEulerAngles = angleLeft; break; case PlayerAngle.RIGHT: transform.localEulerAngles = angleRight; break; } } // 移動方向が待機の場合 if (moveDirection == MoveDirection.STOP) { stopCount = 0; } ChangeAngle(); // アリスの向きを変更 moveAction = MoveAction.RETURN; // アリスの行動を戻るに saveCount--; // 最後の保存場所を変更 // 上下の反転 switch (moveDirection) { case MoveDirection.UP: moveDirection = MoveDirection.DOWN; if (animationClimb2Flag == true) { ResetAnimation(Player.Motion.CLIMB2); } break; case MoveDirection.DOWN: moveDirection = MoveDirection.UP; if (animationClimb1Flag == true) { SetAnimation(Player.Motion.CLIMB2); ResetAnimation(Player.Motion.CLIMB1); } break; } } }
void UpdateImpl(bool damping) { //camera跟随目标的位置 Vector3 cameraPos = Vector3.zero; // float smoothTime = 0; switch (m_curTargetType) { case ENCameraTargetType.enActor: { if (m_targetActor == null) { return; } GameObject obj = m_targetActor.CenterPart; if (m_targetActor.ActionControl.IsActionEmpty() || m_targetActor.ActionControl.IsActionRunning(ActorAction.ENType.enStandAction) || m_targetActor.ActionControl.IsActionRunning(ActorAction.ENType.enActorEnterAction) || IsNormalAttack()) { obj = m_targetActor.MainObj; } cameraPos = null != obj ? obj.transform.position : Vector3.zero; if (!m_targetActor.IsDead) { //主控角色未死亡时,对准主控角色跟目标之间 Actor target = m_targetActor.CurrentTarget; if (target != null && !target.IsDead) { Vector3 selfPos = cameraPos; Vector3 targetPos = target.MainPos; selfPos.y = 0; targetPos.y = 0; cameraPos = selfPos + (targetPos - selfPos) * 0.5f; } } //计算smooth时间 smoothTime = GameSettings.Singleton.m_cameraSmoothTimeForStart; MoveAction action = m_targetActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; if (action != null && CursorEffectFunc.Singleton.CurFingerType != CursorEffectFunc.ENFingerType.enOnDragMoveType) { float d = ActorTargetManager.GetTargetDistance(m_targetActor.RealPos, action.m_realTargetPos); if (d < GameSettings.Singleton.m_cameraStopDistance) { smoothTime = GameSettings.Singleton.m_cameraSmoothTimeForStop; } } else if (m_lastCameraPos == cameraPos) { //目标停止运动 smoothTime = GameSettings.Singleton.m_cameraSmoothTimeForStop; } float velocity = 0; m_currentSmoothTime = Mathf.SmoothDamp(m_currentSmoothTime, smoothTime, ref velocity, GameSettings.Singleton.m_timeForCameraChangeTime); } break; case ENCameraTargetType.enGameObject: { cameraPos = m_targetObj.transform.position; smoothTime = m_changeTime; if (m_autoBackTime != 0) { if (Time.time - m_startTime > m_autoBackTime) { m_changeTime = m_backTime; m_startTime = Time.time; m_curTargetType = ENCameraTargetType.enBackToActor; } } m_currentSmoothTime = smoothTime; } break; case ENCameraTargetType.enPostion: { cameraPos = m_targetPos; smoothTime = m_changeTime; if (m_autoBackTime != 0) { if (Time.time - m_startTime > m_autoBackTime) { m_changeTime = m_backTime; m_startTime = Time.time; m_curTargetType = ENCameraTargetType.enBackToActor; } } m_currentSmoothTime = smoothTime; } break; case ENCameraTargetType.enBackToActor: { GameObject obj = m_targetActor.CenterPart; if (m_targetActor.ActionControl.IsActionEmpty() || m_targetActor.ActionControl.IsActionRunning(ActorAction.ENType.enStandAction) || m_targetActor.ActionControl.IsActionRunning(ActorAction.ENType.enActorEnterAction) || IsNormalAttack()) { obj = m_targetActor.MainObj; } cameraPos = null != obj ? obj.transform.position : Vector3.zero; if (!m_targetActor.IsDead) { //主控角色未死亡时,对准主控角色跟目标之间 Actor target = m_targetActor.CurrentTarget; if (target != null && !target.IsDead) { Vector3 selfPos = cameraPos; Vector3 targetPos = target.MainPos; selfPos.y = 0; targetPos.y = 0; cameraPos = selfPos + (targetPos - selfPos) * 0.5f; } } smoothTime = m_changeTime; if (Time.time - m_startTime > m_changeTime) { m_curTargetType = ENCameraTargetType.enActor; } m_currentSmoothTime = smoothTime; } break; default: { m_curTargetType = ENCameraTargetType.enActor; UpdateImpl(damping); return; } // break; } m_lastCameraPos = cameraPos; if (!m_isChangeY) { cameraPos.y = 0.35f; } //拉远 MainCamera.transform.position = cameraPos; MainCamera.transform.Translate(Vector3.back * GameSettings.Singleton.CameraDistance); MainCamera.transform.rotation = Quaternion.Euler(GameSettings.Singleton.CameraRotate); cameraPos = MainCamera.transform.position; //damp if (damping) { float x = Mathf.SmoothDamp(m_lastCacheCameraPos.x, cameraPos.x, ref xVelocity, m_currentSmoothTime, GameSettings.Singleton.m_smoothMaxSpeed); float y = Mathf.SmoothDamp(m_lastCacheCameraPos.y, cameraPos.y, ref yVelocity, m_currentSmoothTime, GameSettings.Singleton.m_smoothMaxSpeed); float z = Mathf.SmoothDamp(m_lastCacheCameraPos.z, cameraPos.z, ref zVelocity, m_currentSmoothTime, GameSettings.Singleton.m_smoothMaxSpeed); cameraPos = new Vector3(x, y, z); } Vector3 pos = CheckFloat(m_shakeObj.transform.localPosition); //shake cameraPos += pos; MainCamera.transform.position = cameraPos; m_lastCacheCameraPos = cameraPos; }
// 初期化 void Start() { pause = GameObject.Find("Pause"); pauseScript = pause.GetComponent<Pause>(); stage = GameObject.Find("Stage"); stageScript = stage.GetComponent<Stage>(); aliceActionNotifer = new AliceActionNotifer(); aliceActionNotifer.GimmickAry = GameObject.FindGameObjectsWithTag("Gimmick"); // TagがGimmickのオブジェクトを保存 moveAction = MoveAction.NONE; moveBeforePosition = new Vector3(0, 0, 0); saveDirection = MoveDirection.NONE; angleFront = new Vector3(0, 0, 0); angleBack = new Vector3(0, 180, 0); angleLeft = new Vector3(0, 270, 0); angleRight = new Vector3(0, 90, 0); returnFlag = false; // 移動情報を保存する配列の初期化 for (int num = 0; num < SAVE_NUM; num++) { saveMovePlayerAngle[num] = PlayerAngle.NONE; saveMoveDirection[num] = MoveDirection.NONE; saveMoveInput[num] = false; } saveCount = 0; moveCount = 0; moveFlag = false; moveNextFlag = false; autoMoveFlag = false; autoMove = MoveDirection.NONE; moveFinishFlag = false; moveFrontPossibleFlag = false; moveBackPossibleFlag = false; moveLeftPossibleFlag = false; moveRightPossibleFlag = false; animationWalkNextFlag = false; animationWalkReturnFlag = false; animationStayNextFlag = false; animationStayReturnFlag = false; animationDropNextFlag = false; animationDropReturnFlag = false; animationClimb1Flag = false; animationClimb2Flag = false; animationClimb3Flag = false; animationGameOverFlag = false; climbCount = 0; modeSmallFlag = false; modeBigFlag = false; modeSmallCount = 0; modeBigCount = 0; modeSmallTurnCount = 0; modeBigTurnCount = 0; angleArrowFront = new Vector3(90, 0, 0); angleArrowBack = new Vector3(90, 180, 0); angleArrowLeft = new Vector3(90, 270, 0); angleArrowRight = new Vector3(90, 90, 0); climbFrontFlag = false; climbBackFlag = false; climbLeftFlag = false; climbRightFlag = false; climbFront2Flag = false; climbBack2Flag = false; climbLeft2Flag = false; climbRight2Flag = false; climbDropFlag = false; stopCount = 0; }
protected override GameAction PrepareNextActionOverride(out JobStatus progress) { if (m_pathDirs == null || m_supposedLocation != this.Worker.Location) { var res = PreparePath(this.Worker); if (res != JobStatus.Ok) { progress = res; return null; } } Direction dir = m_pathDirs.Dequeue(); if (m_pathDirs.Count == 0) m_pathDirs = null; m_supposedLocation += new IntVector3(dir); GameAction action; if (this.HauledItem == null) action = new MoveAction(dir); else action = new HaulAction(dir, this.HauledItem); progress = JobStatus.Ok; return action; }
private unsafe bool DrawClockConfig(int id, int index, string[] icons, ref bool hasChanged, ref MoveAction moveAction) { switch (id) { case 0: { var et = DateTimeOffset.FromUnixTimeSeconds(*(long *)(Service.Framework.Address.BaseAddress + 0x1608)); DrawClockConfig(index, LocString("Eorzea Time"), icons[0], ref hasChanged, ref TweakConfig.ShowET, ref TweakConfig.CustomFormatET, ref moveAction, et); break; } case 1: { DrawClockConfig(index, LocString("Local Time"), icons[1], ref hasChanged, ref TweakConfig.ShowLT, ref TweakConfig.CustomFormatLT, ref moveAction, DateTimeOffset.Now); break; } case 2: { DrawClockConfig(index, LocString("Server Time"), icons[2], ref hasChanged, ref TweakConfig.ShowST, ref TweakConfig.CustomFormatST, ref moveAction, DateTimeOffset.Now.UtcDateTime); break; } default: { // Broken TweakConfig.Order = new[] { 0, 1, 2 }; SimpleLog.Error("Broken Config Detected. Automatically Fixed"); hasChanged = true; return(false); } } return(true); }
public void Move(MoveAction moveAction) { _moveCoordinator.Move(Surface, this, moveAction); }
/// <summary> /// Gets a reference element based on the given project tree and move action. Can return null. /// The reference element is the element for which moved items will be above or below it. /// </summary> private static ProjectItemElement GetReferenceElement(Project project, IProjectTree projectTree, MoveAction moveAction) { switch (moveAction) { case MoveAction.Up: return(GetElements(project, projectTree).FirstOrDefault()); case MoveAction.Down: return(GetElements(project, projectTree).LastOrDefault()); } return(null); }
/// <summary> /// Gets a sibling of the given project tree based on the move action. Can return null. /// </summary> private static IProjectTree?GetSiblingByMoveAction(IProjectTree projectTree, MoveAction moveAction) { return(moveAction == MoveAction.Above ? GetPreviousSibling(projectTree) : GetNextSibling(projectTree)); }
/// <summary> /// Move project elements based on the given project tree, reference project tree and move action. /// Will modify the project if successful, but not save; only dirty. /// </summary> private static bool TryMove(Project project, IProjectTree projectTree, IProjectTree referenceProjectTree, MoveAction moveAction) { if (!HasValidDisplayOrder(projectTree) || !HasValidDisplayOrder(referenceProjectTree)) { return(false); } if (projectTree == referenceProjectTree) { return(false); } if (referenceProjectTree != null) { // The reference element is the element for which moved items will be above or below it. var referenceElement = GetReferenceElement(project, referenceProjectTree, moveAction); if (referenceElement != null) { var elements = GetElements(project, projectTree); return(TryMoveElements(elements, referenceElement, moveAction)); } } return(false); }
/// <summary> /// Moves child elements based on the reference element and move action. /// </summary> /// <param name="elements"></param> /// <param name="referenceElement">element for which moved items will be above or below it</param> /// <param name="moveAction"></param> /// <returns>true or false; 'true' if all elements were successfully moved. 'false' if just one element was not moved successfully.</returns> private static bool TryMoveElements(ImmutableArray <ProjectItemElement> elements, ProjectItemElement referenceElement, MoveAction moveAction) { Requires.NotNull(referenceElement, nameof(referenceElement)); ProjectElementContainer parent = referenceElement.Parent; if (parent == null || !elements.Any()) { return(false); } // Sanity check bool didAllElementsMove = true; switch (moveAction) { case MoveAction.Above: foreach (ProjectItemElement element in elements) { ProjectElementContainer elementParent = element.Parent; if (elementParent != null) { elementParent.RemoveChild(element); parent.InsertBeforeChild(element, referenceElement); } else { didAllElementsMove = false; } } break; case MoveAction.Below: // Iterate in reverse order when we are wanting to move elements down. // If we didn't do this, the end result would be the moved elements are reversed. for (int i = elements.Length - 1; i >= 0; --i) { ProjectItemElement element = elements[i]; ProjectElementContainer elementParent = element.Parent; if (elementParent != null) { elementParent.RemoveChild(element); parent.InsertAfterChild(element, referenceElement); } else { didAllElementsMove = false; } } break; } return(didAllElementsMove); }
/// <summary> /// Gets a reference element based on the given project tree and move action. Can return null. /// The reference element is the element for which moved items will be above or below it. /// </summary> private static ProjectItemElement TryGetReferenceElement(Project project, IProjectTree projectTree, ImmutableArray <string> excludeIncludes, MoveAction moveAction) { switch (moveAction) { case MoveAction.Above: return(GetItemElements(project, projectTree, excludeIncludes).FirstOrDefault()); case MoveAction.Below: return(GetItemElements(project, projectTree, excludeIncludes).LastOrDefault()); } return(null); }
public AI_Action(MoveAction move, BuyAction buy) { type = Type.Move_And_Buy; this.move = move; this.buy = buy; }
private void DrawClockConfig(int index, string name, string icon, ref bool hasChanged, ref bool enabled, ref string format, ref MoveAction moveAction, DateTimeOffset example) { ImGui.Text(icon); ImGui.SameLine(); // Reordering ImGui.SetWindowFontScale(1.3f); var p2 = ImGui.GetCursorPos(); ImGui.PushFont(UiBuilder.IconFont); var white = new Vector4(1, 1, 1, 1); var other = new Vector4(1, 1, 0, 1); var up = $"{(char)FontAwesomeIcon.SortUp}"; var down = $"{(char)FontAwesomeIcon.SortDown}"; var s = ImGui.CalcTextSize(up); ImGui.BeginGroup(); var p3 = ImGui.GetCursorPos(); var p4 = ImGui.GetCursorScreenPos(); var hoveringUp = ImGui.IsMouseHoveringRect(p4, p4 + new Vector2(s.X, s.Y / 2)); var hoveringDown = !hoveringUp && ImGui.IsMouseHoveringRect(p4 + new Vector2(0, s.Y / 2), p4 + s); if (index > 0) { ImGui.TextColored(hoveringUp ? other : white, up); if (hoveringUp && ImGui.IsMouseClicked(ImGuiMouseButton.Left)) { moveAction = new MoveAction() { Index = index, MoveUp = true }; } } ImGui.SetCursorPos(p3); if (index < 2) { ImGui.TextColored(hoveringDown ? other : white, down); if (hoveringDown && ImGui.IsMouseClicked(ImGuiMouseButton.Left)) { moveAction = new MoveAction() { Index = index, MoveUp = false }; } } ImGui.EndGroup(); ImGui.SetCursorPos(p2 + new Vector2(s.X, 0)); ImGui.PopFont(); ImGui.SetWindowFontScale(1.0f); // End Reordering hasChanged |= ImGui.Checkbox($"###enable{name}", ref enabled); ImGui.SameLine(); ImGui.SetNextItemWidth(120); hasChanged |= ImGui.InputText(name + "##formatEditInput", ref format, 50); ImGui.SameLine(); if (ImGui.GetCursorPosX() > maxX) { maxX = ImGui.GetCursorPosX(); } ImGui.SetCursorPosX(maxX); try { var preview = $"{example.DateTime.ToString(format)}"; ImGui.SetNextItemWidth(120); ImGui.InputText($"###preview{name}", ref preview, 50, ImGuiInputTextFlags.ReadOnly); } catch { ImGui.Text("格式错误"); } }
private void RandomMovement(GameTime gameTime, Ship playership) { List<IDrawableCustom> ships = new List<IDrawableCustom> { playership }; rnd = new Random(); int direction = rnd.Next(1, 5); int fireDelay = rnd.Next(1, 3); if (Math.Abs(gameTime.TotalGameTime.TotalSeconds - this.time) > fireDelay) { this.Fire(gameTime); } if (Math.Abs(gameTime.TotalGameTime.TotalSeconds - this.time) > 1) { switch (direction) { case 1: this.handler = new MoveAction(this.MoveUp); this.time = gameTime.TotalGameTime.TotalSeconds; break; case 2: if(this.Rectangle.Bottom>=GlobalConstants.WINDOW_HEIGHT || playership.Rectangle.Top-this.Rectangle.Bottom<=50) { this.handler = new MoveAction(this.MoveUp); } else { this.handler = new MoveAction(this.MoveDown); } this.time = gameTime.TotalGameTime.TotalSeconds; break; case 3: this.handler = new MoveAction(this.MoveRight); this.time = gameTime.TotalGameTime.TotalSeconds; break; case 4: this.handler = new MoveAction(this.MoveLeft); this.time = gameTime.TotalGameTime.TotalSeconds; break; } } this.handler(ships); }
private void ReturnHome() { aiStatus = AIStatus.returnHome; if (Action != null) { Action.End(); } Action = new MoveAction(this, bornPosition, EndComeHome); }
private void OnMove(MoveAction.Message move) { _state = State.Moving; _moveStart = _boardTheme.PointToVector3(move.From); _moveEnd = _boardTheme.PointToVector3(move.To); transform.position = _moveStart; }
/// <summary> /// Gets a reference element based on the given project tree and move action. Can return null. /// The reference element is the element for which moved items will be above or below it. /// </summary> private static ProjectItemElement?TryGetReferenceElement(Project project, IProjectTree projectTree, ImmutableArray <string> excludeIncludes, MoveAction moveAction) { ImmutableArray <ProjectItemElement> items = GetItemElements(project, projectTree, excludeIncludes); return(moveAction == MoveAction.Above ? items.FirstOrDefault() : items.LastOrDefault()); }
//!角色整体旋转 void RotateMainBody() { if (CurActionType == ActorAction.ENType.enMoveAction) { MoveAction action = CurrentActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; if (null == action) { return; } Vector3 vMainForward = new Vector3(CurrentActor.MainObj.transform.forward.x, 0f, CurrentActor.MainObj.transform.forward.z); //Vector3 vMainForward = mMoveTargetPos - CurrentActor.MainPos; vMainForward.y = 0f; Vector3 vNPCDirection = CurrentActor.TargetManager.CurrentTarget.MainPos - CurrentActor.MainPos; vNPCDirection.y = 0f; float fForwardAngle = Vector3.Angle(vNPCDirection.normalized, mTargetDirection.normalized); //if (!mIsSwitchOn) { if (fForwardAngle >= (mMaxAngle + 10f)) { if (action.AnimName != "backward") { action.AnimName = "backward"; // mIsSwitchOn = true; //Debug.Log("backward"); } } else if (fForwardAngle <= (mMaxAngle - 10f)) { if (action.AnimName != "run") { action.AnimName = "run"; // mIsSwitchOn = true; //Debug.Log("run"); } } //Debug.Log("action.AnimName=" + action.AnimName + " fForwardAngle=" + fForwardAngle + " mIsSwitchOn=" + mIsSwitchOn); } Vector3 vDirection = new Vector3(mTargetDirection.x, 0, mTargetDirection.z); Vector3 vbodyTurnDirection = Vector3.zero; if (action.AnimName == "run") { vbodyTurnDirection = vDirection; } else { vbodyTurnDirection = -vDirection; } float fBodyTurnAngle = Vector3.Angle(vbodyTurnDirection.normalized, vMainForward.normalized); if (fBodyTurnAngle >= -float.Epsilon && fBodyTurnAngle <= float.Epsilon) { return; } float rotateSpeed = Time.deltaTime * GameSettings.Singleton.m_bodyRotateSpeed * 360f; //Debug.Log("bodyTurnAngle=" + fBodyTurnAngle+" rotateSpeed="+rotateSpeed); if (fBodyTurnAngle < rotateSpeed) { CurrentActor.MoveRotation(Quaternion.LookRotation(vbodyTurnDirection.normalized) * Quaternion.LookRotation(Vector3.forward)); return; } //int nRote = 0; float fRote = 0f; if (action.AnimName == "run") { Vector3 verticalVec = Vector3.Cross(vbodyTurnDirection.normalized, new Vector3(0f, 1.0f, 0f)); fRote = Vector3.Angle(verticalVec.normalized, vMainForward.normalized); //nRote = Mathf.RoundToInt(fRote); if (fRote >= 90f) { rotateSpeed = -rotateSpeed; } } else { float fNPCTurnAngle = Vector3.Angle(vbodyTurnDirection.normalized, vNPCDirection.normalized); if (fNPCTurnAngle >= fBodyTurnAngle) { Vector3 verticalVec = Vector3.Cross(vbodyTurnDirection.normalized, new Vector3(0f, 1.0f, 0f)); fRote = Vector3.Angle(verticalVec.normalized, vMainForward.normalized); if (fRote >= 90f) { rotateSpeed = -rotateSpeed; } } else { Vector3 verticalVec = Vector3.Cross(vNPCDirection.normalized, new Vector3(0f, 1.0f, 0f)); fRote = Vector3.Angle(verticalVec.normalized, vMainForward.normalized); if (fRote >= 90f) { rotateSpeed = -rotateSpeed; } } //Debug.Log("fBodyTurnAngle=" + fBodyTurnAngle + " rotateSpeed=" + rotateSpeed + " action.AnimName=" + action.AnimName + " fRote=" + fRote); } //Debug.Log("moveaction"); CurrentActor.MainObj.transform.Rotate(0.0f, rotateSpeed, 0.0f); } else if (CurActionType == ActorAction.ENType.enStandAction) { StandAction action = CurrentActor.ActionControl.LookupAction(ActorAction.ENType.enStandAction) as StandAction; if (null == action) { return; } float fBodyTurnAngle = 0f; Vector3 vDirection = CurrentActor.TargetManager.CurrentTarget.RealPos - CurrentActor.RealPos; vDirection.y = 0f; vDirection.Normalize(); Vector3 vForward = new Vector3(CurrentActor.MainObj.transform.forward.x, 0f, CurrentActor.MainObj.transform.forward.z); vForward.Normalize(); fBodyTurnAngle = Vector3.Angle(vForward.normalized, vDirection.normalized); //m_fCurAngle = 0f; //action.AnimName = "readytofight"; float rotateSpeed = Time.deltaTime * GameSettings.Singleton.m_standRotateSpeed * 360f; if (fBodyTurnAngle < rotateSpeed) { CurrentActor.MoveRotation(Quaternion.LookRotation(vDirection.normalized) * Quaternion.LookRotation(Vector3.forward)); return; } fBodyTurnAngle = rotateSpeed; Vector3 verticalVec = Vector3.Cross(vForward.normalized, new Vector3(0, 1.0f, 0)); verticalVec.Normalize(); float fOtherRot = Vector3.Angle(verticalVec.normalized, vDirection.normalized); if (fOtherRot <= 90f) { fBodyTurnAngle = -fBodyTurnAngle; } Quaternion bodyRotation = Quaternion.Euler(0, fBodyTurnAngle, 0); CurrentActor.MainObj.transform.rotation = bodyRotation * CurrentActor.MainObj.transform.rotation; //CurrentActor.MainObj.transform.Rotate(0.0f, fBodyTurnAngle, 0.0f); //Debug.Log("enStandAction body turn angle="+fBodyTurnAngle); } }
/// <summary> /// Move project elements based on the given project tree, reference project tree and move action. /// Will modify the project if successful, but not save; only dirty. /// </summary> private static bool TryMove(Project project, IProjectTree projectTree, IProjectTree?referenceProjectTree, MoveAction moveAction) { if (!HasValidDisplayOrder(projectTree) || !HasValidDisplayOrder(referenceProjectTree)) { return(false); } if (projectTree == referenceProjectTree) { return(false); } if (referenceProjectTree != null) { // The reference element is the element for which moved items will be above or below it. ProjectItemElement?referenceElement = TryGetReferenceElement(project, referenceProjectTree, ImmutableArray <string> .Empty, moveAction); if (referenceElement != null) { ImmutableArray <ProjectItemElement> elements = GetItemElements(project, projectTree, ImmutableArray <string> .Empty); return(TryMoveElements(elements, referenceElement, moveAction)); } } return(false); }
//!tick public void LateUpdate() { if (GameSettings.Singleton.m_closeActorBlendAnim) { return; } if (CurrentActor.Type == ActorType.enMain && CurrentActor.IsActorExit) { return; } if (CurrentActor.MainPlayerConfig == null || CurrentActor.MainPlayerConfig.m_headTransform == null) { return; } ActorAction.ENType actionType = LastActionType; LastActionType = CurActionType; if (CurActionType != ActorAction.ENType.enStandAction && CurActionType != ActorAction.ENType.enMoveAction) { Reset(); return; } if (CurrentActor.IsDead) { Reset(); return; } if (actionType == ActorAction.ENType.enRollAction && CurActionType == ActorAction.ENType.enStandAction) { m_isRotateUpbody = false; Reset(); return; } else { if (CurActionType != ActorAction.ENType.enStandAction) { m_isRotateUpbody = true; } } bool isHaveTarget = (null != CurrentActor.TargetManager.CurrentTarget); if (isHaveTarget && IsRawRotation()) { MoveAction action = CurrentActor.ActionControl.LookupAction(ActorAction.ENType.enMoveAction) as MoveAction; if (null != action) { action.AnimName = "run"; } return; } if (isHaveTarget) { RotateMainBody(); if (m_isRotateUpbody) { RotateUpBody(); } } else { if (mIsRotateUpBodyWithoutTarget) { RotateUpBodyWithoutTarget(); } } }
public TableValue(TState state, TSymbol symbol, MoveAction action) : base(state, symbol) { _action = action; }
/// <summary> /// Actually executes the move method. /// </summary> private void DoMove(MoveAction action) { OnRowCurrencyChange(); action(); }
public override bool CanPerformAction(MoveAction action) { return(true); }
private void Awake() { entity = GetComponent <Entity>(); action = new MoveAction(); }
// Moves the shadow based on the moveAction // Once movement is done, it redisplays the overlays void MoveShadow(MoveAction moveAction) { if (!IsShadowActive) { ShowShadow(); } CombatBoardManager.Instance.SetObjectOnTileQueued(moveAction.TargetX, moveAction.TargetY, this); System.Action ShowOverlayCallback = CombatManager.Instance.ShowMovementOverlays; CharacterShadow.GetComponent<FriendlyObject>().RunMoveAction(moveAction, ShowOverlayCallback, false); }
/// <summary> /// Check if either of the key combos for the selected action have been pressed /// </summary> /// <param name="moveAction">The action to check</param> /// <param name="keyEventType">The type of key event to check for</param> public static bool CheckMoveAction(MoveAction moveAction) { return(Instance.CheckKeyAction((KeyAction)moveAction, KeyEventType.Hold)); }
/// <summary> /// This function will perform a building cycle if the number of ticks since the last cycle is equal to TICKS_PER_CYCLE. /// </summary> /// <returns>true if the building is complete and the action is finished, false otherwise.</returns> public override bool Work() { if (!building.Completed) { if (curTicks % TICKS_PER_CYCLE == 0) { // Check if unit is adjacent to building. if (isUnitNextToBuilding()) { // Add the building to the model if we have not done so yet. if (building.Parent == null) { // TODO: Ensure that the spaces are cleared. Perhaps wait/give up, as with move? PlayerComponent player = Parent.Parent.Parent.Parent as PlayerComponent; player.BuildingList.AddChild(building); for (int i = (int)building.PointLocation.X; i < building.PointLocation.X + building.Width; i++) { for (int j = (int)building.PointLocation.Y; j < building.PointLocation.Y + building.Height; j++) { building.CellsContainedWithin.Add(map.GetCellAt(i, j)); map.GetCellAt(i,j).AddEntity(building); } } } if (building.MaxHealth - building.CurrentHealth <= ((UnitComponent)Parent.Parent).BuildSpeed) { // Finish the building. building.CurrentHealth = building.MaxHealth; building.Completed = true; } else { // Continue building the building. building.CurrentHealth += ((UnitComponent)Parent.Parent).BuildSpeed; } } else { // Move towards the building. Insert a move action into the Unit's action queue. CellComponent targetCell = findClosestCell(((UnitComponent)Parent.Parent).PointLocation); MoveAction moveAction = new MoveAction(targetCell.X, targetCell.Y, map); Parent.AddChildAt(moveAction, 0); } } } curTicks++; return building.Completed; }
// 移動完了 public void MoveFinish(Vector3 position, ArrayMove arrayMove) { moveFlag = false; // 移動フラグを偽に moveFinishFlag = true; // 移動完了フラグを真に transform.localPosition = position; // 座標を変更 ChangeArrayPosition(arrayMove); // 配列上の位置を変更 moveAction = MoveAction.NONE; // アリスの行動を無しに ModeChange(); //ドラゴン参照 InvisibleCount(); GetKeyCount(); touchCheshireFlag = false; timeFlag = false; timeBackFlag = false; // アニメーションのリセット ResetAnimation(Motion.WALK_NEXT); // 歩き(進む) ResetAnimation(Motion.WALK_RETURN); // 歩き(戻る) ResetAnimation(Motion.STAY_NEXT); ResetAnimation(Motion.STAY_RETURN); }
private void EndAttack() { // Debug.Log("Run AWAY " + Parameters.AttackType); aiStatus = AIStatus.returnHome; if (Action != null) { Action.End(); } Action = new MoveAction(this, bornPosition, EndWalk); }
// 早送り public void MoveNext() { // 移動方向が保存されていれば if (saveMoveDirection[saveCount] != MoveDirection.NONE) { timeFlag = true; moveFlag = true; moveNextFlag = false; moveBeforePosition = transform.position; // 移動前の座標に現在の座標を入れる moveDirection = saveMoveDirection[saveCount]; // 移動方向に移動方向を保存 // キー入力による移動の場合 if(saveMoveInput[saveCount] == true) { ModeCountDown(); // 保存されている移動方向が switch(moveDirection) { case MoveDirection.FRONT: case MoveDirection.BACK: case MoveDirection.LEFT: case MoveDirection.RIGHT: if (animationClimb2Flag == true) { transform.position = new Vector3(transform.position.x, (float)arrayPosY - 0.5f, transform.position.z); SetAnimation(Player.Motion.WALK_NEXT); // 進む時の歩きアニメーションをセット ResetAnimation(Player.Motion.CLIMB1); // 登り途中に } else { ResetPosition(); // アリスの位置をリセット SetAnimation(Motion.WALK_RETURN); ResetAnimation(Player.Motion.CLIMB1); ResetAnimation(Player.Motion.CLIMB2); } break; case MoveDirection.UP: if(animationClimb1Flag == true) { SetAnimation(Player.Motion.CLIMB2); // 登り途中に ResetAnimation(Player.Motion.CLIMB1); // 登り途中に } break; } } // 移動方向が待機の場合 if (moveDirection == MoveDirection.STOP) { stopCount = 0; } // 次の動作がキー入力無しのDOWNの場合(自然落下) if((saveMoveDirection[saveCount + 1] == MoveDirection.DOWN) && (saveMoveInput[saveCount + 1] == false)) { moveNextFlag = true; } ChangeAngle(); // アリスの向きを変更 moveAction = MoveAction.NEXT; // アリスの行動を進めるに saveCount++; // 最後の保存場所を変更 } }