Esempio n. 1
0
    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);
    }
Esempio n. 2
0
    public void DecreaseSelectedShipAction()
    {
        if (selectedObject != null)
        {
            ShipController shipController = selectedObject.GetComponent <ShipController>();

            if (shipController != null && shipController.shipOwner == playerID)
            {
                ShipCommand shipCommand = GetShipCommand(shipController);

                List <ShipAction> shipActions = new List <ShipAction>(GlobalShipActions.ShipActions());

                int currentActionId = shipActions.FindIndex(x => x.name == shipCommand.shipAction.name);

                int newActionId = currentActionId - 1;

                if (newActionId < 0)
                {
                    newActionId = shipActions.Count - 1;
                }

                SetSelectedShipAction(newActionId);
            }
        }
    }
Esempio n. 3
0
    public void SetSelectedShipAction(int actionID)
    {
        if (selectedObject != null && canUpdateCmds)
        {
            ShipController shipController = selectedObject.GetComponent <ShipController>();

            if (shipController != null && shipController.shipOwner == playerID)
            {
                ShipCommand shipCommand = GetShipCommand(shipController);

                List <ShipAction> shipActions = new List <ShipAction>(GlobalShipActions.ShipActions());

                if (shipActions.Count > actionID && 0 <= actionID)
                {
                    List <ShipActionAvailablityEnum> actionAvailability = GameRunner.GetShipActionAvailability(shipController, shipCommand);

                    if (actionAvailability[actionID] == ShipActionAvailablityEnum.ENABLED)
                    {
                        shipCommand.shipAction = shipActions[actionID];
                        shipController.UpdateActionVisual();
                    }
                }
            }
        }

        UpdateCommandUI();
        UpdateInfoUI();
    }
Esempio n. 4
0
 public ShipCommand(ShipCmdState cmd)
 {
     this.shipID = cmd.shipID;
     shipMove    = GlobalShipMoves.ShipMoves()[cmd.moveID];
     shipAction  = GlobalShipActions.ShipActions()[cmd.actionID];
 }
Esempio n. 5
0
 public ShipCommand(int shipID, int moveID, int actionID)
 {
     this.shipID = shipID;
     shipMove    = GlobalShipMoves.ShipMoves()[moveID];
     shipAction  = GlobalShipActions.ShipActions()[actionID];
 }
Esempio n. 6
0
 public ShipCommand(int shipID)
 {
     this.shipID = shipID;
     shipMove    = GlobalShipMoves.ShipMoves()[0];
     shipAction  = GlobalShipActions.ShipActions()[0];
 }
Esempio n. 7
0
 public ShipCommand(ShipController sc)
 {
     this.shipID = sc.shipID;
     shipMove    = GlobalShipMoves.ShipMoves()[0];
     shipAction  = GlobalShipActions.ShipActions()[0];
 }