Ejemplo n.º 1
0
    public Worker PlaceWorker(GameObject workerPrefab, Worker.Gender gender, Worker.Colour colour)
    {
        GameObject newWorker = Instantiate(workerPrefab, new Vector3(transform.position.x, GetWorkerY(), transform.position.z), Quaternion.identity);

        _workerOnTile = newWorker.GetComponent <Worker>();
        _workerOnTile.Initialize(gender, colour);
        _workerOnTile.SetTile(this);
        return(_workerOnTile);
    }
Ejemplo n.º 2
0
    GameObject GetWorkerPrefab(Worker.Gender gender, Worker.Colour colour)
    {
        foreach (WorkerPrefab workerPrefab in _workerPrefabs)
        {
            if (workerPrefab.gender == gender && workerPrefab.colour == colour)
            {
                return(workerPrefab.prefab);
            }
        }

        Debug.LogErrorFormat("Found no Worker prefab with these settings:\nGender: {0}, Colour: {1}", gender.ToString(), colour.ToString());
        return(null);
    }
Ejemplo n.º 3
0
    public void Initialize(InputSystem input, Board board, Worker.Colour colour)
    {
        _input   = input;
        _board   = board;
        _workers = new List <Worker>();
        _colour  = colour;

        _god = new BaseGod();

        _stateMachine = new StateMachine();
        _stateMachine.Initialize(input, board);

        WaitingState waitingState = new WaitingState();

        _stateMachine.RegisterState(waitingState);

        PlacingState placingState = new PlacingState();

        _stateMachine.RegisterState(placingState);

        SelectingState selectingState = new SelectingState();

        _stateMachine.RegisterState(selectingState);

        MovingState movingState = new MovingState();

        _stateMachine.RegisterState(movingState);

        BuildingState buildingState = new BuildingState();

        _stateMachine.RegisterState(buildingState);

        WaitingOnConfirmationState waitingOnConfirmationState = new WaitingOnConfirmationState();

        _stateMachine.RegisterState(waitingOnConfirmationState);

        DoneTurnState doneTurnState = new DoneTurnState();

        _stateMachine.RegisterState(doneTurnState);

        _stateMachine.SetState((int)StateId.Waiting);
    }
Ejemplo n.º 4
0
    public GameObject GetNextWorkerPrefab(out Worker.Gender gender, out Worker.Colour colour)
    {
        int numWorkers = _activePlayer.GetWorkers().Count;

        colour = _activePlayer.GetColour();
        if (numWorkers == 0)
        {
            gender = Worker.Gender.Female;
        }
        else if (numWorkers == 1)
        {
            gender = Worker.Gender.Male;
        }
        else
        {
            // First and Second must be male and female, but any additional workers can be any gender
            gender = (Worker.Gender)UnityEngine.Random.Range(0, 1);
        }

        return(GetWorkerPrefab(gender, colour));
    }