void Awake() { stateCon = FindObjectOfType <GameStateControl>(); WriteToLog("Your Battle Begins!"); stateCon.AssignActivePlayer(); stateMachine.ChangeState(new ClosedState(this)); }
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; }
// 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; }
// Use this for initialization void Awake() { if (instance == null) { DontDestroyOnLoad(gameObject); instance = this; } else if (instance != this) { Destroy(gameObject); } }
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)); } }
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; } }
public CombatState(GameStateControl owner) { this.owner = owner; }
public GameStates(GameStateControl owner) { this.owner = owner; }
public GameOverState(GameStateControl owner) { this.owner = owner; }
public MenuState(GameStateControl owner) { this.owner = owner; }
public MovementState(GameStateControl owner) { this.owner = owner; }
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() } } }