public ActionState ActionStatus(ShipAction AAction) { if (Locked() || (Owner.Role != SSHRole.Self)) { return(ActionState.Hidden); } switch (AAction) { case ShipAction.Annihilation: return(CheckActionAnnihilation()); case ShipAction.ChangeMode: return(CheckActionChangeMode()); case ShipAction.Constructor: return(CheckActionConstructor()); case ShipAction.Delete: return(CheckActionDelete()); case ShipAction.MoveToHangar: return(CheckActionMoveToHangar()); case ShipAction.PortalOpen: return(CheckActionPortalOpen()); case ShipAction.PortalJump: return(CheckActionPortalJump()); default: Debug.Log("Undefined status " + AAction); break; } return(ActionState.Hidden); }
public static List <ShipActionAvailablityEnum> GetShipActionAvailability(ShipController shipController, ShipCommand shipCommand) { ShipAction[] shipActions = GlobalShipActions.ShipActions(); List <ShipActionAvailablityEnum> shipActionAvailabilty = new List <ShipActionAvailablityEnum>(); for (int i = 0; i < shipActions.Length; ++i) { ShipAction a = shipActions[i]; ShipActionAvailablityEnum aa = ShipActionAvailablityEnum.DISABLED; if (a.energyDelta + shipController.energy >= 0) { aa = ShipActionAvailablityEnum.ENABLED; } else { aa = ShipActionAvailablityEnum.CANNOT_USE; } if (GlobalShipActions.GetGlobalActionIndex(shipCommand.shipAction) == i) { aa = ShipActionAvailablityEnum.SELECTED; } shipActionAvailabilty.Add(aa); } return(shipActionAvailabilty); }
public ICommand Create(ShipAction action) { switch (action) { case ShipAction.Forward: return(new ForwardCommand(controlled)); case ShipAction.Backward: return(new BackwardCommand(controlled)); case ShipAction.StrafeLeft: return(new StrafeLeftCommand(controlled)); case ShipAction.StrafeRight: return(new StrafeRightCommand(controlled)); case ShipAction.TurnLeft: return(new TurnLeftCommand(controlled)); case ShipAction.TurnRight: return(new TurnRightCommand(controlled)); case ShipAction.ActivatePowerup: return(new ActivatePowerupCommand(controlled)); case ShipAction.Shoot: return(new ShootCommand(controlled)); default: return(null); } }
private void ItemAdd(ShipAction AShipAction) { MonoUIPopupShipItem tmpItem = new MonoUIPopupShipItem(); tmpItem = PrefabManager.CreateShipPopupItem(FTransform); tmpItem.Init(AShipAction.ToString(), () => { FShip.ActionCall(AShipAction); }); FItems.Add(AShipAction, tmpItem); }
void Start() { myCollider = GetComponent <Collider2D>(); decisionMaker = GetComponentInParent <HumanDecisionMaker>(); action = GetComponent <ShipAction>(); if (action == null) { gameObject.SetActive(false); } }
public static ShipAction[] ShipActions() { ShipAction[] actions = new ShipAction[] { new ShipAction("Basic Energy", ShipActionType.ENERGY, 3), new ShipAction("Basic Rocket", ShipActionType.SHOOT, -2), new ShipAction("Basic Shield", ShipActionType.SHIELD, -3), }; return(actions); }
public void UpdateActionVisual() { ShipAction shipAction = GetShipAction(); if (shipAction.type == ShipActionType.SHOOT) { arcViewController.CreateArc(aimArc, rocketMaxDistance, rocketMinDistance); if (selected) { arcViewController.ShowArc(); } else { arcViewController.DisableArc(); } } else { arcViewController.DisableArc(); } if (shipAction.type == ShipActionType.SHIELD) { if (selected) { shieldVisualController.EnableShieldVisual(); } else { shieldVisualController.DisableShieldVisual(); } } else { shieldVisualController.DisableShieldVisual(); } if (shipAction.type == ShipActionType.ENERGY) { if (selected) { energyVisualController.EnableTriangle(); } else { energyVisualController.DisableTriangle(); } } else { energyVisualController.DisableTriangle(); } }
public void Select() { selectionCircleController.EnableCircle(); pathSelectionController.ShowPath(); ShipAction shipAction = GetShipAction(); if (shipAction.type == ShipActionType.SHOOT) { arcViewController.ShowArc(); } if (shipAction.type == ShipActionType.SHIELD) { shieldVisualController.EnableShieldVisual(); } if (shipAction.type == ShipActionType.ENERGY) { energyVisualController.EnableTriangle(); } }
public void ActionCall(ShipAction AAction) { switch (AAction) { case ShipAction.Annihilation: CallActionAnnihilation(); break; case ShipAction.ChangeMode: CallActionChangeMode(); break; case ShipAction.Constructor: CallActionConstructor(); break; case ShipAction.Delete: CallActionDelete(); break; case ShipAction.MoveToHangar: CallActionMoveToHangar(); break; case ShipAction.PortalOpen: CallActionPortalOpen(); break; case ShipAction.PortalJump: CallActionPortalJump(); break; default: Debug.Log("Undefined call " + AAction); break; } }
internal void Move(ShipAction action, int distance) { switch (action) { case ShipAction.N: Y += distance; break; case ShipAction.E: X += distance; break; case ShipAction.S: Y -= distance; break; case ShipAction.W: X -= distance; break; default: throw new NotImplementedException(); } }
public ShipCommand(int shipID) { this.shipID = shipID; shipMove = GlobalShipMoves.ShipMoves()[0]; shipAction = GlobalShipActions.ShipActions()[0]; }
public ShipTask Join(ILocation target, ShipAction action) { return Join(new ShipTask(target, action)); }
public ShipTask(ILocation target, ShipAction action) { Target = target; Action = action; }
public void ClearCurrentTask() { this.task = null; this.target = null; this.targetAction = null; }
public void ClearTarget() { this.target = null; this.targetAction = null; if (this.task != null) GetNextTask(); }
public void Jump(JumpGate gate) { if (UniversalCoordinates == gate.UniversalCoordinates) gate.Jump(this); else { this.destination = null; this.target = gate; this.targetAction = ((ship, shipTarget) => { gate.Jump(ship); return false; }); } }
public static int GetGlobalActionIndex(ShipAction action) { List <ShipAction> actions = new List <ShipAction>(ShipActions()); return(actions.FindIndex(x => x.name == action.name)); }
public void SetTarget(ILocation newTarget, ShipAction action) { if (action == null) throw new ArgumentNullException("action"); if (Pilot == null) throw new InvalidOperationException("Unable to set ship target without a pilot"); this.target = newTarget; this.targetAction = action; }
public void SetTask(ShipTask args) { if (Pilot == null) throw new InvalidOperationException("Unable to set ship task without a pilot"); this.task = args; this.target = this.task.Target; this.targetAction = this.task.Action; }
private void GetNextTask() { if (this.task == null || this.task.NextTask == null) { this.task = null; this.target = null; this.targetAction = null; } else { this.task = this.task.NextTask; this.target = this.task.Target; this.targetAction = this.task.Action; } }
public ShipCommand(ShipController sc) { this.shipID = sc.shipID; shipMove = GlobalShipMoves.ShipMoves()[0]; shipAction = GlobalShipActions.ShipActions()[0]; }
public bool StepThroughSim() { bool finished = true; if (simTime == 0.0f) { // Setup ship commands foreach (ShipController sc in shipControllers) { ShipCommand cmd = GetShipCommand(sc.shipID); ShipAction action = cmd.shipAction; sc.BeginSimPhase(); // Validate ships have enough energy // Subtract energies switch (action.type) { case ShipActionType.ENERGY: break; case ShipActionType.SHIELD: if (sc.energy + action.energyDelta >= 0) { sc.energy += action.energyDelta; } else { action.complete = true; } break; case ShipActionType.SHOOT: if (sc.energy + action.energyDelta >= 0) { sc.energy += action.energyDelta; sc.SetupSimArcVisual(); } else { action.complete = true; } break; } sc.SetShipMove(cmd.shipMove); } } simTime += simDelta; // Move ships foreach (ShipController sc in shipControllers) { bool doneMove = sc.MoveShip(simDelta); if (!doneMove) { finished = false; } } // TODO // Check if ships collide // Check if ships can Action // if shoot check if enemy ship in sight // if so spawn rocket // if energy add energy // if shield activate shield foreach (ShipController sc in shipControllers) { ShipCommand cmd = GetShipCommand(sc.shipID); ShipAction action = cmd.shipAction; if (!action.complete) { switch (action.type) { case ShipActionType.ENERGY: sc.BoostEnergy(action.energyDelta); action.complete = true; break; case ShipActionType.SHIELD: sc.ActivateShield(); action.complete = true; break; case ShipActionType.SHOOT: ShipController target = sc.GetClosestShipInRangeOfRocket(shipControllers); if (target != null) { RocketController r = sc.FireRocket(target); if (r != null) { action.complete = true; rocketControllers.Add(r); gamePieces.Add(r.gameObject); } } break; } } } // Move rockets // Check if rocket hit anything // If other ship damgage other ship // If other rocket explode other rocket // If so explode rocket foreach (RocketController rocket in rocketControllers.ToArray()) { bool explode = rocket.MoveTowardsTarget(simDelta); foreach (GameObject gp in gamePieces.ToArray()) { { ShipController otherShip = gp.GetComponent <ShipController>(); if (otherShip != null) { if (Vector3.Distance(rocket.transform.position, otherShip.transform.position) < rocketToShipCollisionDistance) { if (rocket.orginShip != otherShip && rocket.orginShip.shipOwner != otherShip.shipOwner) { otherShip.TakeDamage(1, false); explode = true; } } } } { RocketController otherRocket = gp.GetComponent <RocketController>(); if (otherRocket != null) { if (Vector3.Distance(rocket.transform.position, otherRocket.transform.position) < rocketToRocketCollisionDistance) { if (rocket != otherRocket) { ExplodeRocket(otherRocket); explode = true; } } } } } if (explode) { ExplodeRocket(rocket); } } // Check if rockets are still in play if (rocketControllers.Count > 0) { finished = false; } if (finished) { foreach (ShipController sc in shipControllers) { // Check if ship is out of bounds // Take damage if ship is out of bounds if (sc.transform.position.x > squareBoundXPos || sc.transform.position.x < squareBoundXNeg || sc.transform.position.z > squareBoundZPos || sc.transform.position.z < squareBoundZNeg) { sc.TakeDamage(1, true); sc.ShowVisualDamage(serverMode); } sc.EndSimPhase(); } turn++; simTime = 0.0f; } List <int> activePlayerIDs = new List <int>(); foreach (ShipController sc in shipControllers.ToArray()) { if (sc.IsAlive()) { int shipOwner = sc.shipOwner; if (!activePlayerIDs.Contains(shipOwner)) { activePlayerIDs.Add(shipOwner); } } else { // Remove ship from game ExplodeShip(sc); } } // Check if player has won if (activePlayerIDs.Count < 2) { if (activePlayerIDs.Count == 1) { winner = activePlayerIDs[0]; } if (turn - 1 != 0 && finished) { gameOver = true; } } return(finished); }
public ShipCommand(int shipID, int moveID, int actionID) { this.shipID = shipID; shipMove = GlobalShipMoves.ShipMoves()[moveID]; shipAction = GlobalShipActions.ShipActions()[actionID]; }
public ShipCommand(ShipCmdState cmd) { this.shipID = cmd.shipID; shipMove = GlobalShipMoves.ShipMoves()[cmd.moveID]; shipAction = GlobalShipActions.ShipActions()[cmd.actionID]; }
public void SetSelectedAction(ShipAction selectedAction) { this.selectedAction = selectedAction; }
private bool GetAction(ShipAction AAction) { return(FSelf.ActionStatus(AAction) == ActionState.Enabled); }