public override List <Action> GenerateSatisfyingActions(IWorldState worldState, int maxActions) { List <Action> actions = new List <Action>(); IEntity entity = worldState.GetEntity(entityId); float powerDiff = minPower - entity.GetPower(); if (powerDiff <= 0) { return(actions); } ItemFilter filter = new ItemFilter(); filter.requireEquippable = true; for (int i = 0; i < Item.numItemSlots; i++) { if (entity.TryGetEquippedItem((ItemSlot)i, out Item item)) { filter.minPower[i] = powerDiff + item.power; } else { filter.minPower[i] = powerDiff; } } EquipAction equipAction = new EquipAction(worldState, entityId, filter); actions.Add(equipAction); return(actions); }
public PartyTurnActor() { MoveAction moveAction = new MoveAction(m_activeActions); RotateAction rotateAction = new RotateAction(m_activeActions); RestAction restAction = new RestAction(); InteractAction interactAction = new InteractAction(); SelectNextInteractiveObjectAction selectNextInteractiveObjectAction = new SelectNextInteractiveObjectAction(); m_actions = new BaseAction[4][]; for (Int32 i = 0; i < m_actions.Length; i++) { m_actions[i] = new BaseAction[11]; m_actions[i][0] = moveAction; m_actions[i][1] = rotateAction; m_actions[i][6] = restAction; m_actions[i][2] = interactAction; m_actions[i][10] = selectNextInteractiveObjectAction; m_actions[i][3] = new MeleeAttackAction(i); m_actions[i][4] = new RangedAttackAction(i); m_actions[i][9] = new CastSpellAction(i); m_actions[i][5] = new ConsumeItemAction(i); m_actions[i][8] = new DefendAction(i); m_actions[i][7] = new EquipAction(i); } }
public PlayerCharacter(string name, int level, int experience) : base(name) { EquipedWeapon = null; EquipedArmor = null; Level = level; Experience = experience; this.HitPoints = MaxHitPoints; AddActionToList(MoveAction.GetActionBuilder()); AddActionToList(UseAction.GetActionBuilder()); AddActionToList(EquipAction.GetActionBuilder()); }
// override bool IsPlayer{get{return true;}set{}} public PlayerCharacter(string Name) : base(Name) { Experience = 0; EquipedWeapon = null; EquipedArmor = null; this.HitPoints = MaxHitPoints; AddActionToList(MoveAction.GetActionBuilder()); AddActionToList(UseAction.GetActionBuilder()); AddActionToList(EquipAction.GetActionBuilder()); }
void Start() { GameObject weaponObject = Instantiate(weaponPrefab); weaponObject.transform.localScale = Vector3.one * 2; SpiderCannon weapon = weaponObject.GetComponent <SpiderCannon>(); centerTransform = transform.GetChild(0); equipAction = GetComponent <EquipAction>(); equipAction.EquipItem(weapon, centerTransform); }
void Start() { playerView.enabled = true; playerView.transform.position = transform.position + Vector3.up * .5f; playerView.transform.eulerAngles = this.direction = transform.eulerAngles; playerBody = GetComponent <Rigidbody>(); playerCollider = GetComponent <Collider>(); equipAction = GetComponent <EquipAction>(); if (weaponPrefab != null) { Equipment weapon = Instantiate(weaponPrefab, Vector3.zero, Quaternion.Euler(0, 0, 0)).GetComponent <Equipment>(); equipAction.OnEquip(weapon, playerView.transform); } Cursor.lockState = CursorLockMode.Locked; }
void Start() { centerTransform = transform.GetChild(0); centerTransform.rotation = transform.rotation; this.direction = this.transform.eulerAngles; this.position = this.transform.position; this.currentSpeed = 0.0f; targetDetected = targetCanBeSeen = targetInLineOfSight = targetInShootingRange = false; movementAI = GetComponent <MovementAI>(); GameObject weaponObject = Instantiate(weaponPrefab); RangeWeapon weapon = weaponObject.GetComponent <RangeWeapon>(); equipAction = GetComponent <EquipAction>(); equipAction.EquipItem(weapon, this.centerTransform); }
void Start() { playerView.enabled = true; playerView.transform.position = transform.position + Vector3.up * .5f; playerView.transform.eulerAngles = this.direction = transform.eulerAngles; playerView.fieldOfView = 95f; itemAction = GetComponent <EquipAction>(); this.currentSpeed = this.maxSpeed; if (weaponPrefab != null) { GameObject weaponObject = (GameObject)Instantiate(weaponPrefab); RangeWeapon weapon = weaponObject.GetComponent <RangeWeapon>(); itemAction.EquipItem(weapon, playerView.transform); } Cursor.lockState = CursorLockMode.Locked; position = transform.position; }
/// <summary> /// The return is to exit the Game /// </summary> /// <returns></returns> public override bool HandleInput() { var originalColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Black; var inputs = Inputs.Instance; var lastInput = GetPlayerInput(); Console.ForegroundColor = originalColor; var exitGameLoop = false; Action action = null; //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Player Actions. //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- if (lastInput == inputs.forfeit) { var dialog = new ForfeitDialog(_gameState.Game); dialog.Process(); var result = dialog.DialogResult; if (result == ForfeitDialogResult.Yes) { ScreenResult = new ScreenTransitionResult { FromScreen = ScreenType.InGame, ToScreen = ScreenType.MainMenu, Result = null }; Storage.Heroes.RemoveAll(x => x.Name == _gameState.Game.Hero.Name); Storage.Save(); exitGameLoop = true; } } // Input.forfeit, else if (lastInput == inputs.quit) { var dialog = new ConfirmDialog("Are you sure you want to quit the game?"); dialog.Process(); var result = dialog.DialogResult; if (result == ConfirmDialogResult.Yes) { ScreenResult = new ScreenTransitionResult { FromScreen = ScreenType.InGame, ToScreen = ScreenType.MainMenu, Result = null }; Storage.Update(_gameState); Storage.Save(); exitGameLoop = true; } } // Input.quit, else if (lastInput == inputs.closeDoor) { // See how many adjacent open doors there are. var doors = new List <VectorBase>(); foreach (var direction in Direction.All) { var pos = _gameState.Game.Hero.Position + direction; if (_gameState.Game.CurrentStage[pos].Type.ClosesTo != null) { doors.Add(pos); } } if (doors.Count == 0) { _gameState.Game.Log.Error("You are not next to an open door."); } else if (doors.Count == 1) { _gameState.Game.Hero.SetNextAction(new CloseDoorAction(doors[0])); } else { var closeDoorDialog = new CloseDoorDialog(_gameState.Game); closeDoorDialog.Process(); } } // Input.closeDoor, else if (lastInput == inputs.drop) { ShowItemDialog(ItemDialogUsage.Drop); } // Input.drop, else if (lastInput == inputs.use) { ShowItemDialog(ItemDialogUsage.Use); } // Input.use, else if (lastInput == inputs.pickUp) { var items = _gameState.Game.CurrentStage.itemsAt(_gameState.Game.Hero.Position); if (items.Count > 1) { // Show item dialog if there are multiple things to pick up. ShowItemDialog(ItemDialogUsage.PickUp); } else { // Otherwise attempt to pick up any available item. _gameState.Game.Hero.SetNextAction(new PickUpAction(items.Count - 1)); } } // Input.pickUp, else if (lastInput == inputs.swap) { if (_gameState.Game.Hero.Inventory.lastUnequipped == -1) { _gameState.Game.Log.Error("You aren't holding an unequipped item to swap."); } else { action = new EquipAction(ItemLocations.Inventory, _gameState.Game.Hero.Inventory.lastUnequipped); } } // Input.swap, else if (lastInput == inputs.toss) { ShowItemDialog(ItemDialogUsage.Toss); } // Input.toss, else if (lastInput == inputs.selectCommand) { var commands = _gameState.Game.Hero.HeroClass.Commands.Where(cmd => cmd.CanUse(_gameState.Game)); if (!commands.Any()) { _gameState.Game.Log.Error("You don't have any commands you can perform."); } else { Command commandToProcess = null; if (commands.Count() > 1) { var dialog = new SelectCommandDialog(_gameState.Game); dialog.Process(); commandToProcess = dialog.DialogResult; } else { commandToProcess = commands.First(); } if (commandToProcess is TargetCommand) { var targetCommand = commandToProcess as TargetCommand; // If we still have a visible target, use it. if (_gameState.Game.Target != null && _gameState.Game.Target.IsAlive && _gameState.Game.CurrentStage[_gameState.Game.Target.Position].Visible) { _gameState.Game.Hero.SetNextAction(targetCommand.GetTargetAction(_gameState.Game, _gameState.Game.Target.Position)); } else { // No current target, so ask for one. var targetDialog = new TargetDialog(targetCommand.GetRange(_gameState.Game), (target) => _gameState.Game.Hero.SetNextAction(targetCommand.GetTargetAction(_gameState.Game, target)), _gameState.Game); targetDialog.Process(); } } else if (commandToProcess is DirectionCommand) { var directionCommand = commandToProcess as DirectionCommand; var directionDialog = new DirectionDialog(directionCommand, _gameState.Game); directionDialog.Process(); } else { throw new NotImplementedException(); } } } // Input.selectCommand, else if (lastInput == inputs.stats) { ShowHeroStatisticsDialog(); } // Input.HeroStatistics, else if (lastInput.Key == ConsoleKey.Z) { ShowStorageDialog(); } // Storage else if (lastInput.Key == ConsoleKey.Oem3) { ShowConsoleDialog(); } // Storage //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Running Options //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- else if (lastInput == inputs.runNW) { _gameState.Game.Hero.Run(Direction.NorthWest); } // Input.runNW, else if (lastInput == inputs.runN) { _gameState.Game.Hero.Run(Direction.North); } // Input.runN, else if (lastInput == inputs.runNE) { _gameState.Game.Hero.Run(Direction.NorthEast); } // Input.runNE, else if (lastInput == inputs.runW) { _gameState.Game.Hero.Run(Direction.West); } // Input.runW, else if (lastInput == inputs.runE) { _gameState.Game.Hero.Run(Direction.East); } // Input.runE, SemiColon else if (lastInput == inputs.runSW) { _gameState.Game.Hero.Run(Direction.SouthWest); } // Input.runSW, else if (lastInput == inputs.runS) { _gameState.Game.Hero.Run(Direction.South); } // Input.runS, else if (lastInput == inputs.runSE) { _gameState.Game.Hero.Run(Direction.SouthEast); } // Input.runSE, Slash (FWD) //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // Firing Options //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- else if (lastInput == inputs.fireNW) { FireTowards(Direction.NorthWest); } // Input.fireNW, else if (lastInput == inputs.fireN) { FireTowards(Direction.North); } // Input.fireN, else if (lastInput == inputs.fireNE) { FireTowards(Direction.NorthEast); } // Input.fireNE, else if (lastInput == inputs.fireW) { FireTowards(Direction.West); } // Input.fireW, else if (lastInput == inputs.fireE) { FireTowards(Direction.East); } // Input.fireE, else if (lastInput == inputs.fireSW) { FireTowards(Direction.SouthWest); } // Input.fireSW, else if (lastInput == inputs.fireS) { FireTowards(Direction.South); } // Input.fireS, else if (lastInput == inputs.fireSE) { FireTowards(Direction.SouthEast); } // Input.fireSE, //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- // directions. //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------- else if (lastInput == inputs.nw) { action = new WalkAction(Direction.NorthWest); } // Input.nw, else if (lastInput == inputs.n) { action = new WalkAction(Direction.North); } // Input.n, else if (lastInput == inputs.ne) { action = new WalkAction(Direction.NorthEast); } // Input.ne, else if (lastInput == inputs.w) { action = new WalkAction(Direction.West); } // Input.w, else if (lastInput == inputs.rest) { action = new RestAction(); } // Input.l, else if (lastInput == inputs.e) { action = new WalkAction(Direction.East); } // Input.e, else if (lastInput == inputs.sw) { action = new WalkAction(Direction.SouthWest); } // Input.sw, else if (lastInput == inputs.s) { action = new WalkAction(Direction.South); } // Input.s, else if (lastInput == inputs.se) { action = new WalkAction(Direction.SouthEast); } // Input.se, //Check if we have a non-zero value for horizontal or vertical if (action != null) { //UnityEngine.Debugger.Log("Adding action for Hero"); GameState.Instance.Game.Hero.SetNextAction(action); } return(exitGameLoop); }
void Start() { itemAction = GetComponent <EquipAction>(); ownerEntity = GetComponent <Entity>(); inventory = GetComponent <Inventory>(); }