Esempio n. 1
0
    }                                                   //untested

    public static int getAPCost(Game.ActionType action) //Written by Nick Lee, 15-9-2014
    {                                                   //Gets the AP cost of various actions and returns them
        if (action == Game.ActionType.Move)
        {
            return(1);
        }        //If action is move returns AP cost of action type move
        else if (action == Game.ActionType.Reveal)
        {
            return(0);
        }        //If action is reveal returns AP cost of action type reveal
        else if (action == Game.ActionType.ToggleDoor)
        {
            return(1);
        }        //If action is ToggleDoor returns AP cost of action type ToggleDoor
        else if (action == Game.ActionType.Attack)
        {
            return(1);
        }        //If action is Attack returns AP cost of action type Attack
        else if (action == Game.ActionType.Shoot)
        {
            return(1);
        }        //If action is Shoot returns AP cost of action type Shoot
        else if (action == Game.ActionType.Overwatch)
        {
            return(2);                                    //If action is Overwatch returns AP cost of action type Overwatch
        }
        else
        {
            Debug.Log("Invalid action, does not exist (getAPCost, UnitData)");
            return(0);
        } //Error checking and message
    }     //untested
Esempio n. 2
0
    private void update(Game.ActionType actionUpdate, Unit exe)    //Created by Nick Lee 16-9-14, modified 4-11-14
    {
        updateLoS();

        makeActions(actionUpdate, exe);         //make an action array

        marines = game.gameMap.getUnits(Game.EntityType.SM);
        //makes a list of all marine units
        if (executor.unitType == Game.EntityType.GS && !shot)         //if action is made by a genestealer
        {
            for (int i = 0; i < marines.Count; i++)                   //then for each marine
            {
                for (int q = 0; q < marines[i].currentLoS.Count; q++) //then for each square
                {
                    if (marines[i].currentLoS[q] == executor.position && marines[i].isOnOverwatch && !marinesShot.Contains(marines[i]))
                    {
                        overwatchShot = true;                //set overwatch shot to true
                        shot          = true;                //set shot equal to true
                        preExecutor   = executor;
                        shootMethod(marines[i], executor);   //And run a shoot action against the genestealer
                        marinesShot.Add(marines[i]);
                        executor      = preExecutor;
                        shot          = false;
                        overwatchShot = false;                         //set overwatch shot to false
                    }
                }
            }
        }
        marinesShot.Clear();

        marines = game.gameMap.getUnits(Game.EntityType.SM);
        //makes a list of all marine units
        blips = game.gameMap.getUnits(Game.EntityType.Blip);
        //makes a list of all blip units
        for (int i = 0; i < marines.Count; i++)                       //then for each marine
        {
            for (int t = 0; t < blips.Count; t++)                     //and each blip
            {
                for (int u = 0; u < marines[i].currentLoS.Count; u++) //and each square in sight
                {
                    if (marines[i].currentLoS[u] == blips[t].position && !blipsRevealed.Contains(blips[t]))
                    {                     //and the blip isnt already in the list but is within a marines LoS
                        involUnit = executor;
                        blipsRevealed.Add(blips[t]);
                        movementStopped = true;
                        //stops any further movement
                    }
                }
            }
        }
        foreach (Unit blip in blipsRevealed)
        {
            InvoluntaryReveal(blip);              //runs the involuntary reveal for every blip revealed
        }
        blipsRevealed.Clear();

        makePrevLoS();          //makes the previous line of sight
    }
	public ActionManager(Unit unit, Game.ActionType action)	//Contents modified by Nick Lee 16-9-14
	{
		GameObject gameController = GameObject.FindWithTag ("GameController");
		game = gameController.GetComponent<Game> ();
		//gets local game controller
		actionUsed = action; //gets the action
		this.unit = unit; //the unit using the action
		marines = game.gameMap.getUnits (Game.EntityType.SM);
		makePrevLoS ();
	}
Esempio n. 4
0
    public ActionManager(Unit unit, Game.ActionType action)     //Contents modified by Nick Lee 16-9-14
    {
        GameObject gameController = GameObject.FindWithTag("GameController");

        game = gameController.GetComponent <Game> ();
        //gets local game controller
        actionUsed = action;      //gets the action
        this.unit  = unit;        //the unit using the action
        marines    = game.gameMap.getUnits(Game.EntityType.SM);
        makePrevLoS();
    }
Esempio n. 5
0
    private void makeActions(Game.ActionType actionMade, Unit exe)     //Created by Nick Lee 23-9-14, modified 5-11-14
    {
        executor   = exe;
        actionType = actionMade;         //gets action made
        finishLoS();
        //gets the updated LoS for all marines
        APCost = UnitData.getAPCost(actionType);         //gets the AP cost of the action
        if (overwatchShot)
        {
            APCost = 0;
        }

        if (actionType == Game.ActionType.Move)
        {
            executie     = null;          //no target unit for moving
            movePosition = moving;        //position to move to set by moving
            moveFacing   = compassFacing; //facing set by compass facing
            if (!sittingStill)
            {
                APCost = UnitData.getMoveSet(executor.unitType)[Movement];                 //APCost depends on type of movement
            }
            else
            {
                APCost       = 0;
                sittingStill = false;
            }
            unitJams = false;             //cant jam
            voidSustainedFire(executor);
            voidOverwatch(executor);
        }
        else if (actionType == Game.ActionType.Attack)
        {
            voidOverwatch(executor);
            voidOverwatch(executie);
            movePosition = executor.position;         //no position change
            moveFacing   = executor.facing;           //no facing change
            voidSustainedFire(executor);
            voidSustainedFire(executie);
            unitJams = false;
        }
        else if (actionType == Game.ActionType.Shoot)
        {
            movePosition = executor.position;         //position unchanged
            moveFacing   = executor.facing;           //facing unchanged
        }
        else if (actionType == Game.ActionType.ToggleDoor)
        {
            voidSustainedFire(executor);
            voidOverwatch(executor);
            unitJams = false;
        }
        else if (actionType == Game.ActionType.Overwatch)
        {
            executie     = null;              //no target unit
            movePosition = executor.position; //no change movement
            moveFacing   = executor.facing;   //no change in facing
            unitJams     = false;             //no jamming
        }
        else
        {
            Debug.Log("Error with action type , ActionManager, makeActions");
        }
        //error message and catching

        returnAction.actionType           = actionType;
        returnAction.executor             = executor;
        returnAction.target               = executie;
        returnAction.movePosition         = movePosition;
        returnAction.moveFacing           = moveFacing;
        returnAction.APCost               = APCost;
        returnAction.unitJams             = unitJams;
        returnAction.destroyedUnits       = destroyedUnits;
        returnAction.sustainedFireLost    = sustainedFireLost;
        returnAction.completeLoS          = completeLoS;
        returnAction.prevLoS              = prevLoS;
        returnAction.sustainedFireChanged = sustainedFireChanged;
        returnAction.lostOverwatch        = lostOverwatch;
        returnAction.diceRoll             = dieRolled;
        actions.Add(returnAction);
        //creates a return Action and adds it to the list of actions

        resetVariables();
    }
	private void makeActions(Game.ActionType actionMade, Unit exe) //Created by Nick Lee 23-9-14, modified 5-11-14
	{
		executor = exe;
		actionType = actionMade; //gets action made
		finishLoS ();
		//gets the updated LoS for all marines
		APCost = UnitData.getAPCost(actionType); //gets the AP cost of the action
		if (overwatchShot)
			APCost = 0;

		if (actionType == Game.ActionType.Move) {
			executie = null; //no target unit for moving
			movePosition = moving; //position to move to set by moving
			moveFacing = compassFacing; //facing set by compass facing
			if(!sittingStill)
				APCost = UnitData.getMoveSet(executor.unitType)[Movement]; //APCost depends on type of movement
			else
			{
				APCost = 0;
				sittingStill = false;
			}
			unitJams = false; //cant jam
			voidSustainedFire(executor);
			voidOverwatch(executor);
		}
		else if (actionType == Game.ActionType.Attack) {
			voidOverwatch(executor);
			voidOverwatch(executie);
			movePosition = executor.position; //no position change
			moveFacing = executor.facing; //no facing change
			voidSustainedFire(executor);
			voidSustainedFire(executie);
			unitJams = false;
		}
		else if (actionType == Game.ActionType.Shoot) {
			movePosition = executor.position; //position unchanged
			moveFacing = executor.facing; //facing unchanged
		}
		else if (actionType == Game.ActionType.ToggleDoor) {
			voidSustainedFire(executor);
			voidOverwatch(executor);
			unitJams = false;
		}
		else if (actionType == Game.ActionType.Overwatch) {
			executie = null; //no target unit
			movePosition = executor.position; //no change movement
			moveFacing = executor.facing; //no change in facing
			unitJams = false; //no jamming
		} else
			Debug.Log ("Error with action type , ActionManager, makeActions");
		//error message and catching

		returnAction.actionType = actionType;
		returnAction.executor = executor;
		returnAction.target = executie;
		returnAction.movePosition = movePosition;
		returnAction.moveFacing = moveFacing;
		returnAction.APCost = APCost;
		returnAction.unitJams = unitJams;
		returnAction.destroyedUnits = destroyedUnits;
		returnAction.sustainedFireLost = sustainedFireLost;
		returnAction.completeLoS = completeLoS;
		returnAction.prevLoS = prevLoS;
		returnAction.sustainedFireChanged = sustainedFireChanged;
		returnAction.lostOverwatch = lostOverwatch;
		returnAction.diceRoll = dieRolled;
		actions.Add (returnAction);
		//creates a return Action and adds it to the list of actions
		
		resetVariables ();
	}