private void CreateDestructiblePile() { // Create our destructible pile (other player's will be created by them and synced over the network) string prefabPath = "Prefabs/GameScene/NetworkResources/Resources/DestructiblePile1"; GameObject destructiblePileGo = null; if (this.GameType == GameType_t.SINGLE_PLAYER) { destructiblePileGo = PrefabLoader.Instance.InstantiateSynchronous(prefabPath, this.View.DestructiblePile1Anchor); } else { Transform anchor = MultiPlayerManager.Instance.AreWePlayer1() ? this.View.DestructiblePile1Anchor : this.View.DestructiblePile2Anchor; destructiblePileGo = MultiPlayerManager.Instance.InstantiatePrefab(prefabPath, anchor); } destructiblePileGo.AssertNotNull("Destructible pile game object"); // Do this to make sure that the destructible piles are mirrors of each other if (this.GameType == GameType_t.MULTI_PLAYER && !MultiPlayerManager.Instance.AreWePlayer1()) { destructiblePileGo.transform.rotation = Quaternion.AngleAxis(180, Vector3.up); } DestructiblePile destructiblePile = destructiblePileGo.GetComponent <DestructiblePile>(); destructiblePile.AssertNotNull("Destructible pile component"); }
private void LoadNextProjectile() { // Check because this is called from a coroutine if (this == null || this.View == null) { return; } // Already have a projectile if (this._currentProjectile != null) { return; } GameObject projectileGO = null; if (this._gameController.GameType == GameController.GameType_t.SINGLE_PLAYER) { projectileGO = PrefabLoader.Instance.InstantiateSynchronous(kProjectilePrefabPath, this.View.LaunchPosition); } else { projectileGO = MultiPlayerManager.Instance.InstantiatePrefab(kProjectilePrefabPath, this.View.LaunchPosition); } projectileGO.AssertNotNull("Projectile game object"); this._currentProjectile = projectileGO.GetComponent <Projectile>(); this._currentProjectile.AssertNotNull("Projectile component"); Rigidbody2D rigidbody2D = projectileGO.GetComponent <Rigidbody2D>(); rigidbody2D.AssertNotNull("RigidBody2D component"); rigidbody2D.gravityScale = 0.0f; }
private void CreateView() { GameObject go = PrefabLoader.Instance.InstantiateSynchronous(kGameViewPrefabPath); go.AssertNotNull("Game View Prefab"); this.View = go.GetComponent <GameView>(); this.View.AssertNotNull("Game View Component"); // If we are player 2 in the game, we flip the camera horizontally // This way, each player thinks they are the player on the left if (this.GameType == GameType_t.MULTI_PLAYER && !MultiPlayerManager.Instance.AreWePlayer1()) { this.View.FlipCameraHorizontal(); } this.UIController = new UIGameController(this); this.UIController.PresentDialog(); }
public void CreateView(Transform anchor) { // Only instantiate prefab if this is our player. Other player's view is synced over the network if (this.PlayerType == PlayerType_t.Us) { GameObject go = null; switch (this._gameController.GameType) { case GameController.GameType_t.SINGLE_PLAYER: { go = PrefabLoader.Instance.InstantiateSynchronous(kPlayerViewPrefabPath, anchor); } break; case GameController.GameType_t.MULTI_PLAYER: { go = MultiPlayerManager.Instance.InstantiatePrefab(kPlayerViewPrefabPath, anchor); } break; } go.AssertNotNull("Player view game object"); this.View = go.GetComponent <PlayerView>(); this.View.AssertNotNull("Player view component"); this.LoadNextProjectile(); } }