Пример #1
0
    void Awake()
    {
        stateCon = FindObjectOfType <GameStateControl>();

        WriteToLog("Your Battle Begins!");

        stateCon.AssignActivePlayer();
        stateMachine.ChangeState(new ClosedState(this));
    }
Пример #2
0
 public void Enter()
 {
     gameState = GameObject.Find("GameStateController").GetComponent <GameStateControl>();
     gameState.stateMachine.ChangeState(new MenuState(gameState));
     Time.timeScale = 0;
     owner.menuPanel.SetActive(true);
     owner.systemPanel.SetActive(true);
     Cursor.visible   = true;
     Cursor.lockState = CursorLockMode.Confined;
 }
Пример #3
0
 // Start is called before the first frame update
 void Awake()
 {
     hud          = GameObject.Find("HUD").GetComponent <HUDControl>();
     gameState    = GameObject.Find("GameStateController").GetComponent <GameStateControl>();
     move         = GetComponent <PlayerMovement>();
     stats        = GetComponent <Stats>();
     con          = GetComponent <CharacterController>();
     curWounds    = stats.wounds;
     curEndurance = stats.endurance;
     weapon       = GetComponent <PlayerAttack>().weapon;
 }
Пример #4
0
// Use this for initialization
    void Awake()
    {
        if (instance == null)
        {
            DontDestroyOnLoad(gameObject);
            instance = this;
        }
        else if (instance != this)
        {
            Destroy(gameObject);
        }
    }
Пример #5
0
    public void Enter()
    {
        Time.timeScale = 1;
        owner.menuPanel.SetActive(false);
        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Locked;
        gameState        = owner.stateCon;

        if (gameState.activePlayer.GetComponent <PlayerControl>().combatActive)
        {
            gameState.stateMachine.ChangeState(new CombatState(gameState));
        }
        else
        {
            gameState.stateMachine.ChangeState(new MovementState(gameState));
        }
    }
Пример #6
0
    public void FindTarget()
    {
        GameStateControl stateCon     = FindObjectOfType <GameStateControl>();
        Transform        tempTarget   = null;
        float            tempDistance = 0;
        bool             allNull      = false;

        foreach (EnemyControl enemy in stateCon.allEnemies)
        {
            if (enemy != null)
            {
                allNull = false;
                break;
            }
            else
            {
                allNull = true;
            }
        }

        if (!allNull)
        {
            foreach (EnemyControl enemy in stateCon.allEnemies)
            {
                if (enemy != null)
                {
                    float dis = Vector3.Distance(transform.position, enemy.transform.position);

                    if (dis < tempDistance || tempDistance == 0)
                    {
                        tempDistance = dis;
                        tempTarget   = enemy.transform;
                    }
                }
            }
            target = tempTarget;
        }
    }
Пример #7
0
 public CombatState(GameStateControl owner)
 {
     this.owner = owner;
 }
Пример #8
0
 public GameStates(GameStateControl owner)
 {
     this.owner = owner;
 }
Пример #9
0
 public GameOverState(GameStateControl owner)
 {
     this.owner = owner;
 }
Пример #10
0
 public MenuState(GameStateControl owner)
 {
     this.owner = owner;
 }
Пример #11
0
 public MovementState(GameStateControl owner)
 {
     this.owner = owner;
 }
Пример #12
0
        public virtual void OnTriggerPressed(ControllerInteractionEventArgs e)
        {
            if (TriggerPressed != null)
            {
                TriggerPressed(this, e);
            }
            GameObject rightController = GameObject.Find("Controller (right)");
            Collider   menuCol         = rightController.GetComponent <VRTK_SimplePointerRight> ().menuCol;
            Collider   col             = rightController.GetComponent <VRTK_SimplePointerRight> ().col;
            //Todo: allow some action in room choose mode
            GameStateControl gameStateControl = GameObject.Find("GameController").GetComponent <GameStateControl>();

            //special handle for tooltip and exit

            if (menuCol != null && (menuCol.transform.parent.gameObject == GameObject.Find("MenuCubeToolTip") || menuCol.transform.parent.gameObject == GameObject.Find("MenuCubeExit")))
            {
                GameObject.Find("MainCubeMenu").GetComponent <MainMenuScript>().selectSubMenu(menuCol);
                rightController.GetComponent <VRTK_SimplePointerRight>().menuCol = null;
                return;
            }
            if (gameStateControl.State == GameStateControl.GameState.IN_ROOM)
            {
                if (menuCol != null)
                {
                    if (GameObject.Find("GameController").GetComponent <GameStateControl>().showingCubeMenu)
                    {
                        GameObject.Find("MainCubeMenu").GetComponent <MainMenuScript>().selectSubMenu(menuCol);
                        menuCol = null;
                        return;
                    }
                    if (GameObject.Find("GameController").GetComponent <GameStateControl>().showingItemMenu)
                    {
                        menuCol.GetComponentInParent <MenuItemBehavior>().CreateModel();
                        if (GameObject.Find("GameController").GetComponent <GameStateControl>().showingtips)
                        {
                            gameStateControl.DisableAllTips();
                            gameStateControl.enableRoomTips();
                        }
                        rightController.GetComponent <VRTK_SimplePointerRight>().menuCol = null;
                        GameObject.Find("GameController").GetComponent <GameStateControl>().TurnOnOffItemMenu();
                        return;
                    }
                }
            }
            if (GameObject.Find("GameController").GetComponent <GameStateControl>().State == GameStateControl.GameState.DELETE)
            {
                if (col != null && rightController.GetComponent <VRTK_SimplePointerRight>().pointerHitColor == Color.red)
                {
                    GameObject.DestroyImmediate(col.gameObject);
                    col = null;
                    return;
                }
            }
            if (GameObject.Find("GameController").GetComponent <GameStateControl>().State == GameStateControl.GameState.ROOM_CHOOSER)
            {
                if (col != null)
                {
                    GameObject GameController = GameObject.Find("GameController");
                    Vector3    cameraOldPos   = GameObject.Find("[CameraRig]").transform.position;
                    Vector3    cameraNewPos   = GameObject.Find(col.transform.parent.gameObject.name + "/anchor").transform.position;
                    GameObject.Find("[CameraRig]").transform.position      = cameraNewPos;//Vector3.Lerp(cameraOldPos, cameraNewPos, Time.deltaTime * 5f);
                    GameController.GetComponent <GameStateControl>().State = GameStateControl.GameState.IN_ROOM;
                    rightController.GetComponent <VRTK_SimplePointerRight>().restoreCeilingMaterial();
                    rightController.GetComponentInChildren <RightControllerButtonHandler>().setMenusToDefault();//left
                    rightController.GetComponentInChildren <RightControllerButtonHandler>().changeRightToDefault();
                    if (GameController.GetComponent <GameStateControl>().showingtips)
                    {
                        if (GameController.GetComponent <GameStateControl>().showingCubeMenu)
                        {
                            return;
                        }
                        GameController.GetComponent <GameStateControl>().DisableAllTips();
                        GameController.GetComponent <GameStateControl>().enableRoomTips();
                    }
                    // moveCamera()
                }
            }
        }