Exemple #1
0
 void SetState(GuardStates nextState)
 {
     if (nextState != curState)
     {
         oldState = curState;
         curState = nextState;
     }
 }
Exemple #2
0
    public Guard(SimpleRoute route)
    {
        _lastId++;
        _id = _lastId;

        _patrol      = route;
        _routeLength = route.PatrolRoutePhen.Count;
        _guardState  = GuardStates.Patrol;
    }
Exemple #3
0
    // Start is called before the first frame update
    void Start()
    {
        _agent = GetComponent <NavMeshAgent>();
        Vector3 newDestination = new Vector3(transform.position.x + Random.Range(0.0f, 1.0f), transform.position.y, transform.position.z + Random.Range(0.0f, 1.0f));

        _agent.SetDestination(newDestination);

        currentState = GuardStates.Patrol;
    }
Exemple #4
0
    private void UpdateChaseState()
    {
        SetRandomDestinationForAgentNearTarget(player, 1.0f, -1.0f);

        if (!LineOfSight(player))
        {
            currentState = GuardStates.Patrol;
            Debug.Log("Switch to patrol state");
        }
    }
Exemple #5
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                this.Background = Brushes.Transparent;
            }

            ProtectionState = App.Configuration.ProtectionState;

            DataContext = App.UIViewModels.ShortLongBreakTimeRemaining;
        }
Exemple #6
0
    private void UpdatePatrolState()
    {
        if (_agent.remainingDistance <= _agent.stoppingDistance)
        {
            SetRandomDestinationForAgentNearTarget(transform, 5.0f, -5.0f);
        }


        if (Vector3.Distance(transform.position, player.position) < sightReach && LineOfSight(player))
        {
            currentState = GuardStates.Chase;
            Debug.Log("Switch to chase state");
        }
    }
Exemple #7
0
 public static void UpdateIntruptOfStats(GuardStates state)
 {
     if (state == GuardStates.PausedProtecting)
     {
         Configuration.PauseCount++;
         Configuration.SaveSettingsToFile();
         UIViewModels.Stats.PauseCount = Configuration.PauseCount;
     }
     else if (state == GuardStates.NotProtecting)
     {
         Configuration.StopCount++;
         Configuration.SaveSettingsToFile();
         UIViewModels.Stats.StopCount = Configuration.StopCount;
     }
 }
Exemple #8
0
    // Use this for initialization
    void Start()
    {
        fsm.Add(GuardStates.PATROL, PatrolState);
        fsm.Add(GuardStates.IDLE, IdleState);
        fsm.Add(GuardStates.PAUSE, PauseState);
        fsm.Add(GuardStates.ENTERANGRY, EnterAngryState);
        fsm.Add(GuardStates.ANGRY, AngryState);
        fsm.Add(GuardStates.EXITANGRY, ExitAngryState);

        anim     = GetComponent <Animator> ();
        Actor    = GetComponent <AnimDataModel> ();
        Manage   = GameObject.Find("DebugManager").GetComponent <DebugManager> ();
        curState = GuardStates.IDLE;
        oldState = GuardStates.IDLE;
//        if (Actor.isActive)
//			{
        SetState(GuardStates.PATROL);
//				PatrolState ();
//			}
    }
Exemple #9
0
    void Behaviours()
    {
        if (_hasSpotted == true)
        {
            Debug.Log("Spotted");

            _audioSource.clip = guardSounds[0];
            _audioSource.Play();

            alertedSprite.SetActive(true);

            //Stops the Coroutine if the Enemy spots the Player.
            StopCoroutine(PatrolState());

            //Set the Guards State to Attack.
            states = GuardStates.attacking;
        }
        else if (_hasSpotted == false)
        {
            alertedSprite.SetActive(false);
            states = GuardStates.patrolling;
        }
    }
Exemple #10
0
        private void GuardButton_Click(object sender, RoutedEventArgs e)
        {
            if (App.CheckIfResting())
            {
                return;
            }

            if (ProtectionState == GuardStates.Protecting)
            {
                ProtectionState = GuardStates.NotProtecting;
                if (App.Configuration.SaveStats)
                {
                    UpdateIntruptOfStats(GuardStates.NotProtecting);
                }
            }
            else if (ProtectionState == GuardStates.NotProtecting)
            {
                ProtectionState = GuardStates.Protecting;
            }
            else if (ProtectionState == GuardStates.PausedProtecting)
            {
                App.ResumeProtection();
            }
        }
Exemple #11
0
    // Update is called once per frame
    void Update()
    {
        if (inventoryCanvas.GetComponent <CanvasBahavior>().IsCanvasActive() && usingInventory == false)
        {
            inventoryCanvas.GetComponent <CanvasBahavior>().DeactivateInventory();
        }

        if (instructionCanvas.GetComponent <InstructionCanvas>().IsCanvasActive() && usingInstructions == false)
        {
            instructionCanvas.GetComponent <InstructionCanvas>().HideInstructions();
        }
        moveAmount = DiceRoll.movement;
        current    = GameObject.Find("StateMachine").GetComponent <GameState>().GetObjectFromState();
        if (GameState.currentPlayer == GetComponent <Player>().playerState)
        {
            isMyTurn = true;
        }
        else
        {
            isMyTurn = false;
        }

        inputAvailable--;

        //if(GameObject.Find("GuardState").GetComponent<GuardStates>().)
        if (GuardStates.IsGuardState())
        {
            controllingGuard = true;
        }
        else
        {
            controllingGuard = false;
        }


        if (controllingGuard == false)
        {
            if (isMyTurn && usingInventory != true && usingInstructions != true)
            {
                if (inputAvailable <= 0 && moveAmount > 0 && movesMade < moveAmount)
                {
                    if (Input.GetAxis("Vertical") > .5)
                    {
                        if (GameController.CheckForWalls(pos.x, (pos.y + moveSize)) == false &&
                            GameController.CheckForPlayer(pos.x, (pos.y + moveSize)) == false &&
                            GameController.CheckForGuard(pos.x, (pos.y + moveSize)) == false)
                        {
                            pos.y         += moveSize;
                            inputAvailable = 20;
                            movesMade++;
                        }

                        //transform.localPosition
                    }

                    else if (Input.GetAxis("Vertical") < -.5)
                    {
                        if (GameController.CheckForWalls(pos.x, (pos.y - moveSize)) == false &&
                            GameController.CheckForPlayer(pos.x, (pos.y - moveSize)) == false &&
                            GameController.CheckForGuard(pos.x, (pos.y - moveSize)) == false)

                        {
                            pos.y         -= moveSize;
                            inputAvailable = 20;
                            movesMade++;
                        }
                    }

                    else if (Input.GetAxis("Horizontal") > .5)
                    {
                        if (GameController.CheckForWalls((pos.x + moveSize), pos.y) == false &&
                            GameController.CheckForPlayer((pos.x + moveSize), pos.y) == false &&
                            GameController.CheckForGuard((pos.x + moveSize), pos.y) == false)
                        {
                            pos.x         += moveSize;
                            inputAvailable = 20;
                            movesMade++;
                        }
                    }

                    else if (Input.GetAxis("Horizontal") < -.5)
                    {
                        if (GameController.CheckForWalls((pos.x - moveSize), pos.y) == false &&
                            GameController.CheckForPlayer((pos.x - moveSize), pos.y) == false &&
                            GameController.CheckForGuard((pos.x - moveSize), pos.y) == false)
                        {
                            pos.x         -= moveSize;
                            inputAvailable = 20;
                            movesMade++;
                        }
                    }
                    transform.position = pos;
                }

                if (Input.GetKeyDown(KeyCode.R))
                {
                    if (interractionCheck != 0)
                    {
                        print("you cannot reset your action");
                        //TODO
                    }
                    else
                    {
                        pos = resetPosition;
                        transform.position = pos;
                        movesMade          = 0;
                    }
                }

                if (Input.GetKeyDown(KeyCode.E))
                {
                    print("end turn");
                    //TODO
                    //EndTurn();

                    pos               = transform.position;
                    resetPosition     = transform.position;
                    interractionCheck = 0;
                    inputAvailable    = 0;
                    movesMade         = 0;//moveAmount;
                    //hasRolled = true;
                    moveAmount = 0;
                    //GetComponent<DiceRoll>().coroutineAllowed = true;
                    GameObject.Find("StateMachine").GetComponent <GameState>().NextPlayer();
                    GameObject.Find("DiceRoller").GetComponent <DiceRoll>().coroutineAllowed = true;
                    DiceRoll.movement = 0;
                    //TODO-something with the dice
                }

                if (interractionCheck == 0)
                {
                    if (Input.GetKeyDown(KeyCode.X))
                    {
                        print("control guard");
                        //TODO
                        pos = resetPosition;
                        //resetPosition = transform.position;
                        //interractionCheck = 0;
                        inputAvailable = 0;
                        movesMade      = 0;
                        //hasRolled = true;
                        moveAmount = 0;
                        GameObject.Find("GuardState").GetComponent <GuardStates>().NextState();
                        //GameObject.Find("StateMachine").GetComponent<GameState>().NextPlayer();

                        //GameObject.Find("DiceRoller").GetComponent<DiceRoll>().coroutineAllowed = true;
                        //DiceRoll.movement = 0;
                        //TODO-something with the dice
                    }
                }

                if (GameController.CheckForInterractions(pos.x, pos.y) == true)
                {
                    //Check which room
                    if (Input.GetKeyDown(KeyCode.Return))
                    {
                        if (interractionCheck != 0)
                        {
                            print("you can only do that once per turn");
                            //TODO-output sound
                        }
                        else
                        {
                            //TODO-change database
                            List <Item> db  = GameObject.Find("Items").GetComponent <ItemDatabase>().getDatabaseFromPosition(pos.x, pos.y);
                            Item        itm = GameObject.Find("Items").GetComponent <ItemDatabase>().drawAndRemove(db);

                            if (itm != null)
                            {
                                if ((current.GetComponent <Player>().heldItems.Count < 5) &&
                                    itm.use != "stat" && itm.type != "hazard")
                                {
                                    print("item added to inventory");
                                    current.GetComponent <Player>().heldItems.Add(itm);
                                }

                                else if (itm.use == "stat")
                                {
                                    int amount = 0;
                                    if (itm.rare == true)
                                    {
                                        amount = 2;
                                    }
                                    else if (itm.rare == false)
                                    {
                                        amount = 1;
                                    }

                                    if (itm.location == "library")
                                    {
                                        current.GetComponent <Player>().intelligence += amount;
                                    }
                                    else if (itm.location == "yard")
                                    {
                                        current.GetComponent <Player>().strength += amount;
                                    }
                                    else if (itm.location == "shower")
                                    {
                                        current.GetComponent <Player>().looks += amount;
                                    }
                                    print("stats added to your stats");
                                    GameObject.Find("Items").GetComponent <ItemDatabase>().ReturnItem(itm);
                                }
                                else if (itm.type == "hazard")
                                {
                                    if (itm.identifier == -1)
                                    {
                                        //go to infirmary
                                        transform.position = HazardMovement.getRandomInfirmaryPoint();
                                        pos           = transform.position;
                                        resetPosition = transform.position;
                                    }
                                    else if (itm.identifier == -2)
                                    {
                                        //go to solitary
                                        transform.position = HazardMovement.getRandomSolitaryPoint();
                                        pos           = transform.position;
                                        resetPosition = transform.position;
                                    }
                                    print("hazard");
                                    GameObject.Find("Items").GetComponent <ItemDatabase>().ReturnItem(itm);
                                }

                                else if ((current.GetComponent <Player>().heldItems.Count >= 5) &&
                                         itm.use != "stat" && itm.type != "hazard")
                                {
                                    print("Inventory is full");
                                    GameObject.Find("Items").GetComponent <ItemDatabase>().ReturnItem(itm);
                                }

                                if (itm.rare == true)
                                {
                                    if (GameObject.Find("Items").GetComponent <ItemDatabase>().totalLuck != 0)
                                    {
                                        current.GetComponent <Player>().luck += 1;
                                        GameObject.Find("Items").GetComponent <ItemDatabase>().totalLuck -= 1;
                                    }
                                }
                                interractionCheck++;
                                movesMade = moveAmount;
                            }
                            else
                            {
                                print("There are no items left here");
                                //TODO-make a thud sound
                            }
                        }
                    }
                }

                //TODO-win conditions based on exit
                if (GameController.CheckForExits(pos.x, pos.y) == true)
                {
                    //TODO Check which room & check for win condition
                    GameObject.Find("Winning").GetComponent <WinTheGame>().CheckExit(current);
                }

                /*
                 * if(Input.GetKeyDown(KeyCode.C)){
                 *  Camera.pixelWidth = 3840f;
                 *  Camera.pixelHeight = 2560f;
                 * }
                 */
            }//end of isMyTurn
             //TODO-disable when fighting
            if (Input.GetKeyDown(KeyCode.I) && usingInstructions == false)
            {
                //print("Inventory");
                if (usingInventory == false)
                {
                    usingInventory = true;
                    inventoryCanvas.GetComponent <CanvasBahavior>().ActivateInventory();
                }
                else
                {
                    inventoryCanvas.GetComponent <CanvasBahavior>().DeactivateInventory();
                    usingInventory = false;
                }
            }

            if (Input.GetKeyDown(KeyCode.U) && usingInventory == false)
            {
                if (usingInstructions == false)
                {
                    usingInstructions = true;
                    instructionCanvas.GetComponent <InstructionCanvas>().ShowInstructions();
                }
                else
                {
                    instructionCanvas.GetComponent <InstructionCanvas>().HideInstructions();
                    usingInstructions = false;
                }
            }
        }
    }
Exemple #12
0
        const Int32 LIVE_TIME      = LiveControler.LIVE_TIME; //Doba na odpoved = GUARD_INTERVAL * LIVE_TIME

        public LiveControlerArgs(GuardStates new_state, UInt32 interval)
        {
            this.state    = new_state;
            this.Interval = interval;
        }
 void SwitchToAttacking(GameObject target)
 {
     state = GuardStates.Attacking;
     GetComponent<Renderer>().material.color = new Color(1.0f, 0.0f, 0.0f);
 }
 void SwitchToGuarding()
 {
     state = GuardStates.Guarding;
     GetComponent<Renderer>().material.color = new Color(0.0f, 1.0f, 0.0f);
     SelectRandomPatrolPoint();
     playerOfInterest = null;
 }
 void SwitchToChasing(GameObject target)
 {
     state = GuardStates.Chasing;
     GetComponent<Renderer>().material.color = new Color(1.0f, 1.0f, 0.0f);
     playerOfInterest = target;
 }
Exemple #16
0
        const Int32 LIVE_TIME = LiveControler.LIVE_TIME; //Doba na odpoved = GUARD_INTERVAL * LIVE_TIME

        #endregion Fields

        #region Constructors

        public LiveControlerArgs(GuardStates new_state,  UInt32 interval)
        {
            this.state = new_state;
            this.Interval = interval;
        }