Example #1
0
    /***********************************************************************************
     * Function Name: Update
     * Description: Called once per frame.
     **********************************************************************************/
    void Update()
    {
        Ray        ray = GameCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;

        //Raycast will only hit player 1
        //TODO: Add functionality for player 2
        if (Physics.Raycast(ray, out hitInfo, 25.0f, LayerMask.GetMask("Worker")))
        {
            //If worker is clicked, "select" it and indicate it with a material change.
            if (Input.GetMouseButtonDown(0))
            {
                //TODO: ADD A CONDITIONAL FOR PROMETHEUS -  workers can choose to build, move(but cannot move up), then build again
                PlayerWorker tempWorker = hitInfo.collider.gameObject.GetComponent <PlayerWorker>();
                //UpdateCamera(selectedWorker);

                //Check if worker belongs to player
                if (GameManager.instance.WorkerCurrentPlayer(tempWorker))
                {
                    selectedWorker = tempWorker;
                    GameManager.instance.SelectWorker(selectedWorker);
                    selectedWorker.owner.currentGodCard.ExitState();
                }
            }
        }
    }
Example #2
0
    public override void PlaceWorker(PlayerWorker worker, Space space)
    {
        Debug.Log("Using Minotaur Place Worker");
        //If not at game start and there is an opposing worker at the space to move to
        if (worker.currentSpace && space.workerAtSpace)
        {
            worker.enabled = false;
            worker.currentSpace.workerAtSpace = null;
            GameManager.instance.MinotaurCharge.Play();
            BloodEffect.PlayEffectOnce(NewOpponentSpace(worker.currentSpace, space).spacePosition);
            base.PlaceWorker(space.workerAtSpace, NewOpponentSpace(worker.currentSpace, space));

            //Force the opposing worker to the space the current worker is occupying
            //worker.enabled = false;
            //base.PlaceWorker(space.workerAtSpace, worker.currentSpace);
            //Move the worker, don't use base function because current space's worker is not set to null because opposing worker was forced there
            space.workerAtSpace = worker;
            worker.currentSpace = space;
            // Calls helper method in the gameUI class to place worker

            GameManager.instance.gameUI.PlaceWorker(worker, space);

            worker.enabled = true;
        }
        else //Use default move if not
        {
            base.PlaceWorker(worker, space);
        }
    }
Example #3
0
    public override void PlaceWorker(PlayerWorker worker, Space selectedSpace)
    {
        Debug.Log("Using Athena PlaceWorker");
        //for athena, we need to find out if they move a worker up
        base.PlaceWorker(worker, selectedSpace);                        //do the normal movement, this updates levelChangePerTurn

        GameManager.instance.IsAthenaActive(worker.owner);              //now we determine if athena is activated after movement
    }
Example #4
0
    public override void PlaceWorker(PlayerWorker worker, Space space)
    {
        if (worker.currentSpace.GetSpaceFloorLevel() - space.GetSpaceFloorLevel() >= 2)
        {
            movedDownTwoLevels = true;
        }

        base.PlaceWorker(worker, space);
    }
Example #5
0
    /***********************************************************************************
     * Function Name: Start
     * Description: Used for initialization.
     **********************************************************************************/
    void Start()
    {
        blockedByDome = false;                       // Game starts with no domes
        workerAtSpace = null;                        // Game starts prior to players choosing starting spaces
        building      = null;

        // Record the address of this space
        spacePosition     = new Vector3(transform.position.x, transform.position.y, transform.position.z);
        currentFloorLevel = FloorLevel.ground;
    }
Example #6
0
    /***********************************************************************************
     * Script Name: PlaceWorker
     * Description: Move a worker to a space (Animation related)
     **********************************************************************************/
    public void PlaceWorker(PlayerWorker worker, Space selectedSpace)
    {
        worker.transform.position = new Vector3(selectedSpace.spacePosition.x, selectedSpace.GetHeight(), selectedSpace.spacePosition.z);

        if (worker.owner.currentGodCard.name == "Hermes" && GameManager.instance.currentPlayer == worker.owner && GameManager.instance.currentMode != GameManager.Mode.SettingUp)
        {
            HermesSpeed.Play();
            PlayEffectOnce(HermesDust, worker.transform.position);
        }
    }
Example #7
0
    public override List <Space> GetAvailableMoves(PlayerWorker worker)
    {
        List <Space> AvailableMoves = base.GetAvailableMoves(worker);

        //Cannot move upward if player built before moving
        if (buildBeforeMove)
        {
            AvailableMoves.RemoveAll(moves => (int)moves.GetSpaceFloorLevel() - (int)worker.currentSpace.GetSpaceFloorLevel() > 0);
        }

        return(AvailableMoves);
    }
Example #8
0
    public override List <Space> GetAvailableBuilds(PlayerWorker worker)
    {
        List <Space> AvailableBuilds = base.GetAvailableBuilds(worker);

        //Remove the space that was just built on
        if (!firstBuild)
        {
            AvailableBuilds.Remove(firstBuildSpace);
        }

        return(AvailableBuilds);
    }
Example #9
0
    //TODO THIS IS NOT OVERRIDING THE APOLLO GetAvailableMoves()... would have to hardcode Side effect to all gods....
    //restrict movement
    public override List <Space> GetAvailableMoves(PlayerWorker worker)
    {
        Debug.Log("Athena restriction called");
        List <Space> availableMoves = new List <Space>();

        availableMoves.AddRange(worker.currentSpace.AdjSpaces);
        //Remove all spaces that are higher
        availableMoves.RemoveAll(moves => (int)moves.GetSpaceFloorLevel() - (int)worker.currentSpace.GetSpaceFloorLevel() >= 1);
        //Remove all spaces that are blocked by domes
        availableMoves.RemoveAll(moves => moves.blockedByDome);
        return(availableMoves);
    }
Example #10
0
    /***********************************************************************************
     * Function Name: DetermineAvailableMovement
     * Description: This function determines if there are any changes to available movements
     *              for that worker and outputs a Space List of legal moves for that worker
     **********************************************************************************/
    public List <Space> GetPossibleMovementsForWorker(PlayerWorker worker)
    {
        List <Space> AvailableMoves = new List <Space>();

        //Get available moves allowed by player's god card
        AvailableMoves = worker.owner.currentGodCard.GetAvailableMoves(worker);

        //If Athena was activated, take out all moves that lead upward
        if (instance.AthenaActivated)
        {
            AvailableMoves.RemoveAll(moves => (int)moves.GetSpaceFloorLevel() - (int)worker.currentSpace.GetSpaceFloorLevel() > 0);
        }

        return(AvailableMoves);
    }
Example #11
0
    /***********************************************************************************
     * Function Name: StartMovementPhase
     * Description:  This function determines how to proceed with the movement logic
     *  For instance, is this movement phase restricted in some way (Athena), or enhanced in someway
     *  i.e. (Apollo- allows swapping of positions, Minotaur- allows pushing players, Artemis- allows 2 spaces of movement)
     **********************************************************************************/

    public void StartMovementPhase(PlayerWorker worker, Space selectedSpace)
    {
        //Determine if there are any movement restrictions
        //TODO: Add Hermes conditional
        if (AthenaActivated)
        {
            worker.owner.currentGodCard.PlaceWorker(worker, selectedSpace);
            instance.AthenaActivated = false;                //turn off effect afterwards
        }
        else
        {
            //move with no restrictions, or move with god ability
            worker.owner.currentGodCard.PlaceWorker(worker, selectedSpace);
        }
    }
Example #12
0
    /***********************************************************************************
     * Function Name: SetWorkerStartingSpace
     * Description: Setter function set PlayerWorker's starting space
     **********************************************************************************/
    void SetWorkerStartingSpace(PlayerWorker worker)
    {
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit, 25.0f, LayerMask.GetMask("Tile")))
        {
            Space clickedSpace = hit.collider.gameObject.GetComponent <Space>();
            if (clickedSpace.workerAtSpace != null)
            {                                                                   //did the user click on a space that's already occupied by another worker? then do not assign space to worker's currentSpace
                return;
            }
            MoveWorkerToSpace(worker, clickedSpace);
        }
    }
Example #13
0
    /***********************************************************************************
     * Function Name: ExitBuildState
     * Description: Exit Build State and Enter Select Worker state for next player
     **********************************************************************************/
    public void ExitBuildState()
    {
        //Reset worker + space selection
        GameManager.instance.ResetSelection(selectedWorker);
        selectedWorker = null;
        selectedSpace  = null;

        //End current player's turn
        GameManager.instance.EndTurn();

        //Enter worker selector state for other player
        WorkerSelector workerSelect = GetComponent <WorkerSelector>();

        workerSelect.EnterState();
    }
Example #14
0
    /***********************************************************************************
     * Function Name: GetAvailableBuilds
     * Description: Get the available moves for a worker
     **********************************************************************************/
    public List <Space> GetAvailableBuilds(PlayerWorker worker)
    {
        List <Space> availableBuilds = new List <Space>();

        availableBuilds.AddRange(worker.currentSpace.AdjSpaces);

        //Remove all spaces with workers
        //TODO: Conditionals for God cards
        availableBuilds.RemoveAll(moves => moves.workerAtSpace != null);

        //Remove all spaces that are blocked by domes
        availableBuilds.RemoveAll(moves => moves.blockedByDome);

        return(availableBuilds);
    }
Example #15
0
    public override List <Space> GetAvailableMoves(PlayerWorker worker)
    {
        List <Space> finalOutput;
        Space        starting = worker.currentSpace;        //starting spot of worker

        AdjToWorkerSpace = base.GetAvailableMoves(worker);
        List <Space> Legal = new List <Space>();            //Legal set of avaiable moves for hermes

        FloodFill(starting, Legal);
        Legal.RemoveAll(temp => temp.workerAtSpace != null);                //remove workers
        Legal.RemoveAll(temp => temp.blockedByDome);

        finalOutput = AdjToWorkerSpace.Union(Legal).ToList();
        return(finalOutput);
    }
Example #16
0
    /***********************************************************************************
     * Function Name: EnterBuildState
     * Description: Enter Build State
     **********************************************************************************/
    public void EnterBuildState(PlayerWorker worker)
    {
        //added by Brian for ActionPhase UI
        GameManager.instance.currentPhase = GameManager.ActionPhase.Build;

        //Set state to build
        state = State.build;

        selectedWorker = worker;
        this.enabled   = true;

        availableSpaces = selectedWorker.owner.currentGodCard.GetAvailableBuilds(worker);

        //Highlight availableSpaces
        highlightAvailableSpaces();
    }
Example #17
0
    /***********************************************************************************
     * Function Name: EnterMoveState
     * Description: Enter Move State
     **********************************************************************************/
    public void EnterMoveState(PlayerWorker worker)
    {
        //added by Brian for ActionPhase UI
        GameManager.instance.currentPhase = GameManager.ActionPhase.Move;

        //Set state to move
        state = State.move;

        selectedWorker = worker;
        this.enabled   = true;


        availableSpaces = GameManager.instance.GetPossibleMovementsForWorker(worker);
        //Highlight availableSpaces
        highlightAvailableSpaces();
    }
Example #18
0
    /***********************************************************************************
     * Function Name: MoveWorkerToSpace
     * Description: This is the normal movement function
     **********************************************************************************/
    public void MoveWorkerToSpace(PlayerWorker worker, Space selectedSpace)
    {
        if (instance.currentMode == Mode.Playing)           //added this conditional to keep track of worker level changes, used for Athena ability
        {
            worker.owner.levelChangeDuringTurn = GetFloorLevelChange(worker.currentSpace, selectedSpace);
        }
        if (worker.currentSpace)
        {
            worker.currentSpace.workerAtSpace = null;
        }
        selectedSpace.workerAtSpace = worker;
        worker.currentSpace         = selectedSpace;
        // Calls helper method in the gameUI class to place worker
        gameUI.PlaceWorker(worker, selectedSpace);

        // Moving floor placement offset logic to GameUI.cs
    }
Example #19
0
    /***********************************************************************************
     * Function Name: GetAvailableMoves
     * Description: Get the typically available moves for a worker with no buffs/debuffs
     **********************************************************************************/
    public List <Space> GetAvailableMoves(PlayerWorker worker)
    {
        List <Space> availableMoves = new List <Space>();

        availableMoves.AddRange(worker.currentSpace.AdjSpaces);

        //Remove all spaces with worker
        availableMoves.RemoveAll(moves => moves.workerAtSpace != null);

        //Remove all spaces that are too high or too low
        availableMoves.RemoveAll(moves => (int)moves.GetSpaceFloorLevel() - (int)worker.currentSpace.GetSpaceFloorLevel() > 1);

        //Remove all spaces that are blocked by domes
        availableMoves.RemoveAll(moves => moves.blockedByDome);

        return(availableMoves);
    }
Example #20
0
    public override List <Space> GetAvailableMoves(PlayerWorker worker)
    {
        List <Space> availableMoves = new List <Space>();

        availableMoves.AddRange(worker.currentSpace.AdjSpaces);

        //Keep spaces with opposing workers
        availableMoves.RemoveAll(moves => moves.workerAtSpace && moves.workerAtSpace.owner == GameManager.instance.currentPlayer);

        availableMoves.RemoveAll(moves => (moves.workerAtSpace != null && !CanPushWorker(worker.currentSpace, moves)));
        //Remove all spaces that are too high or too low
        availableMoves.RemoveAll(moves => (int)moves.GetSpaceFloorLevel() - (int)worker.currentSpace.GetSpaceFloorLevel() > 1);

        //Remove all spaces that are blocked by domes
        availableMoves.RemoveAll(moves => moves.blockedByDome);

        return(availableMoves);
    }
Example #21
0
    /***********************************************************************************
     * Function Name: ExitMoveState
     * Description: Exit Move State and Enter Build state
     **********************************************************************************/
    public void ExitMoveState()
    {
        //Reset space selection
        selectedSpace = null;

        //Check win condition
        if (selectedWorker.owner.currentGodCard.HasCurrentPlayerWon())
        {
            //Reset worker selection
            GameManager.instance.ResetSelection(selectedWorker);
            selectedWorker = null;

            //End Game
            GameManager.instance.EndGame();
        }
        else
        {
            //Enter build state
            selectedWorker.owner.currentGodCard.EnterBuildState(selectedWorker);
        }
    }
Example #22
0
    public override void PlaceWorker(PlayerWorker worker, Space space)
    {
        Debug.Log("Using Apollo Place Worker");
        //If not at game start and there is an opposing worker at the space to move to
        if (worker.currentSpace && space.workerAtSpace)
        {
            //Force the opposing worker to the space the current worker is occupying
            worker.enabled = false;
            base.PlaceWorker(space.workerAtSpace, worker.currentSpace);
            //Move the worker, don't use base function because current space's worker is not set to null because opposing worker was forced there
            space.workerAtSpace = worker;
            worker.currentSpace = space;
            // Calls helper method in the gameUI class to place worker

            GameManager.instance.gameUI.PlaceWorker(worker, space);
            GameManager.instance.flash.FlashAttack();
            worker.enabled = true;
        }
        else //Use default move if not
        {
            base.PlaceWorker(worker, space);
        }
    }
Example #23
0
    //Allows a worker to move twice, but not back to the original spot
    public override List <Space> GetAvailableMoves(PlayerWorker worker)
    {
        Debug.Log("Inside Artemis's GetAvailableMoves");
        List <Space> finalAvailableMoves = new List <Space>();
        List <Space> tempMoves;

        finalAvailableMoves = base.GetAvailableMoves(worker);

        //If Athena was activated, take out all moves that lead upward
        if (GameManager.instance.AthenaActivated)
        {
            finalAvailableMoves.RemoveAll(moves => (int)moves.GetSpaceFloorLevel() - (int)worker.currentSpace.GetSpaceFloorLevel() > 0);
        }

        //Get all moves possible for a second move
        foreach (Space moves in finalAvailableMoves)
        {
            tempMoves = new List <Space>();

            tempMoves.AddRange(moves.AdjSpaces);

            //Remove all spaces with worker
            tempMoves.RemoveAll(temp => temp.workerAtSpace != null);

            //Remove all spaces that are too high or too low
            tempMoves.RemoveAll(temp => (int)temp.GetSpaceFloorLevel() - (int)moves.GetSpaceFloorLevel() > 1);

            //Remove all spaces that are blocked by domes
            tempMoves.RemoveAll(temp => temp.blockedByDome);

            //Union with available moves
            finalAvailableMoves = finalAvailableMoves.Union(tempMoves).ToList();
        }
        //removing any space with domes (vs Atlas)

        return(finalAvailableMoves);
    }
Example #24
0
 /***********************************************************************************
  * Script Name: ResetSelection
  * Description: Reset worker selection.
  **********************************************************************************/
 public void ResetSelection(PlayerWorker worker)
 {
     worker.DeselectWorker();
 }
Example #25
0
 /***********************************************************************************
  * Script Name: SelectWorker
  * Description: Show worker selection.
  **********************************************************************************/
 public void SelectWorker(PlayerWorker worker)
 {
     worker.SelectWorker();
 }
Example #26
0
 public virtual void EnterMoveState(PlayerWorker worker)
 {
     GameManager.instance.gameUI.GetComponent <TileSelector>().EnterMoveState(worker);
 }
Example #27
0
 public virtual List <Space> GetAvailableBuilds(PlayerWorker worker)
 {
     return(GameManager.instance.GetAvailableBuilds(worker));
 }
Example #28
0
 public virtual void PlaceWorker(PlayerWorker worker, Space space)
 {
     GameManager.instance.MoveWorkerToSpace(worker, space);
 }
Example #29
0
 /***********************************************************************************
  * Function Name: Start
  * Description: Used for initialization.
  **********************************************************************************/
 void Start()
 {
     enabled        = false;
     selectedWorker = null;
 }
Example #30
0
 public PlayerManager(DataContext context)
 {
     _context      = context ?? throw new Exception("The context cannot be null.");
     _playerWorker = new PlayerWorker(_context);
 }