InstantiateSceneObject() public static method

Instantiate a scene-owned prefab over the network. The PhotonViews will be controllable by the MasterClient. This prefab needs to be located in the root of a "Resources" folder.
Only the master client can Instantiate scene objects. Instead of using prefabs in the Resources folder, you can manually Instantiate and assign PhotonViews. See doc.
public static InstantiateSceneObject ( string prefabName, Vector3 position, Quaternion rotation, int group, object data ) : GameObject
prefabName string Name of the prefab to instantiate.
position Vector3 Position Vector3 to apply on instantiation.
rotation Quaternion Rotation Quaternion to apply on instantiation.
group int The group for this PhotonView.
data object Optional instantiation data. This will be saved to it's PhotonView.instantiationData.
return GameObject
Ejemplo n.º 1
0
    public void SpawnHoles()
    {
        int y;
        int x;

        for (int i = 0; i < 10; i++)
        {
            y = Random.Range(-90, -30);
            x = Random.Range(10, 152);
            PhotonNetwork.InstantiateSceneObject("Holes", new Vector3((float)x, (float)y, 10f), Quaternion.identity, 0, null);
            if (x < 153)
            {
                GameObject lava = GameObject.Find("GenLava(Clone)");
                lava.GetComponent <PhotonView>().RPC("SetInitialBlock", PhotonTargets.All, x, y - (int)lava.GetComponent <Lava>().offset_y);
            }
        }
        for (int i = 0; i < 10; i++)
        {
            y = Random.Range(5, 90);
            x = Random.Range(154, 300);
            PhotonNetwork.InstantiateSceneObject("Holes", new Vector3((float)x, (float)y, 10f), Quaternion.identity, 0, null);
            if (x > 153)
            {
                GameObject water = GameObject.Find("GenWater(Clone)");
                //Debug.Log (x + "/" + (y - (int)lavaScript.offset_y));
                water.GetComponent <PhotonView>().RPC("SetInitialBlock", PhotonTargets.All, x - (int)water.GetComponent <Lava>().offset_x, y);
            }
        }
    }
Ejemplo n.º 2
0
    void SpawnMonsters(object sender, EventArgs e)
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }

        //get all of spawn points in the scene
        EnemySpawnPoint[] sceneSpawnPoints = FindObjectsOfType <EnemySpawnPoint>();

        foreach (EnemySpawnPoint spawnPoint in sceneSpawnPoints)
        {
            string objectToSpawn = string.Empty;

            if (spawnPoint.CustomEnemySpawn != null)
            {
                objectToSpawn = spawnPoint.CustomEnemySpawn.name;
            }

            if (objectToSpawn == string.Empty)
            {
                objectToSpawn = GetMonsterBasedOnWeights(spawnPoint.MinimumWeight, spawnPoint.MaximumWeight);
            }

            //use photon to instantiate the object over the network
            GameObject obj = PhotonNetwork.InstantiateSceneObject("AI/" + objectToSpawn, spawnPoint.transform.position, spawnPoint.transform.rotation, 0, null);

            RoomManager.Instance.AddEnemyToRoom(obj.GetComponent <AI>(), spawnPoint.SpawnPointRoom);
        }
    }
Ejemplo n.º 3
0
    public static Wall SpawnWallMultiplayer(ref Transform parent)
    {
        var wall = PhotonNetwork.InstantiateSceneObject("Wall", Vector3.zero, Quaternion.identity).GetComponent <Wall>();

        wall.Transform.SetParent(parent);
        return(wall);
    }
Ejemplo n.º 4
0
 void AddFood()
 {
     if (PhotonNetwork.isMasterClient)
     {
         PhotonNetwork.InstantiateSceneObject("food", new Vector3(Random.Range(-20, 20), Random.Range(-95, -5), Random.Range(-20, 20)), Quaternion.Euler(Random.Range(0, 180), Random.Range(0, 180), Random.Range(0, 180)), 0, null);
     }
 }
Ejemplo n.º 5
0
    //checks if everyplayer is in the room and  ready to play
    public void PlayersReady()
    {
        int xVal = 0;

        for (int i = 0; i < 2; i++)
        {
            GameObject prefab = PhotonNetwork.InstantiateSceneObject(Dice.name, new Vector3(xVal, 2, 0), Quaternion.identity);

            int prefabViewID = prefab.GetComponent <PhotonView>().ViewID;
            if (i == 0)
            {
                prefab.name = "Dice1";
                SetRoomProperty(DICE_1_HASHKEY, prefabViewID);
            }
            else if (i == 1)
            {
                prefab.name = "Dice2";
                SetRoomProperty(DICE_2_HASHKEY, prefabViewID);
            }

            xVal += 3;//seperates the second dice from the first one
        }
        int starterIndex = UnityEngine.Random.Range(1, PhotonNetwork.PlayerList.Length + 1);

        SetRoomProperty(PLAYER_IN_ACTION_HASHKEY, starterIndex);
        SetRoomProperty(GAME_STATE_HASHKEY, 1);
    }
Ejemplo n.º 6
0
    void SpanwEnemy(Transform _enemy)
    {
        int     i     = Random.Range(0, spawnPoints.Length);
        Vector3 spawn = spawnPoints[i].transform.position;

        PhotonNetwork.InstantiateSceneObject(Path.Combine("PhotonPrefabs", _enemy.name), spawn, Quaternion.identity);
    }
Ejemplo n.º 7
0
 public void Update()
 {
     if (_network.IsMine)
     {
         if (!_currentFlag)
         {
             if (_countdown < 0.0f)
             {
                 SpawnPoint spawn = _PickSpawn();
                 Vector3?   pos   = spawn.GetSpawnLocation();
                 if (pos.HasValue)
                 {
                     _currentFlag = PhotonNetwork.InstantiateSceneObject(
                         Path.Combine("CaptureTheFlag", "Flag"), pos.Value, Quaternion.identity
                         );
                 }
             }
             else
             {
                 _countdown -= Time.deltaTime;
             }
         }
         else
         {
             _countdown = SpawnDelay;
         }
     }
 }
Ejemplo n.º 8
0
    // Start is called before the first frame update
    void Start()
    {
        PhotonNetwork.Instantiate(RealPlayer.name, Vector3.zero, Quaternion.identity);

        // PhotonNetwork.InstantiateSceneObject(Sphere.name, new Vector3(0f, 4f, 0f), Quaternion.identity);
        if (PhotonNetwork.IsMasterClient)
        {
            for (int i = 0; i < 5; i++)
            {
                GameObject go = PhotonNetwork.InstantiateSceneObject(capsule.name, new Vector3(Random.Range(-10f, 10f), 1f, Random.Range(-10f, 10f)), Quaternion.identity);
                go.name = capsule.name + i;
            }
        }



        if (PhotonNetwork.IsMasterClient)
        {
            foreach (Player player in PhotonNetwork.PlayerList)
            {
                GameObject go = PhotonNetwork.InstantiateSceneObject(Cube.name, new Vector3(Random.Range(-5f, 5f), 2f, Random.Range(-5f, 5f)), Quaternion.identity);
                go.transform.name = player.NickName;
            }
        }

        foreach (Player player in PhotonNetwork.PlayerList)
        {
            //go.name = player.NickName;
        }
    }
Ejemplo n.º 9
0
    public void ChooseMap()
    {
        Debug.Log("choosemap");
        GameObject a = PhotonNetwork.InstantiateSceneObject(TileMaps[Random.Range(0, 6)].name, Vector2.zero, UnityEngine.Quaternion.identity, 0, null);

        tagOfmap = a.tag;
    }
Ejemplo n.º 10
0
    public void AsMasterSpawnBotsForAllPlayers(MapData mapData)
    {
        if (PhotonNetwork.isMasterClient)
        {
            if (mapData.bots != null)
            {
                for (int i = 0; i < mapData.bots.Count; i++)
                {
                    BotPrefab prefab = botsList.FirstOrDefault(p => p.type == mapData.bots[i].type);

                    for (int j = 0; j < mapData.bots[i].count; j++)
                    {
                        Vector3    tankPos = Vector3.zero;
                        Quaternion tankRot = Quaternion.identity;

                        GameObject tank = PhotonNetwork.InstantiateSceneObject(prefab.prefab.name, tankPos, tankRot, 0, null);
                        tank.GetComponent <BOTSetup>().AsMasterSetIDForAllPlayers(BotID(prefab.type, j));
                    }
                }
            }
            else
            {
                Debug.LogWarning("MapData do not have bots list");
            }
        }
    }
    //IEnumerator Sync ()
    //{
    //    while (true)
    //    {
    //        yield return new WaitForSecondsRealtime(0.1f);
    //        photonView.RPC("SyncFoodSpawnerRPC",PhotonTargets.Others,licznik,licznkiDynamit,licznkiNaprawiarka,licznkiZasoby,licznkiCoin);
    //    }
    //}

    //[PunRPC]
    //void SyncFoodSpawnerRPC (int LICZNIK,int LICZNIKDYNAMIT, int LICZNIKNAPRAWIARKA, int LICZNIKZASOBY, int LICZNIKCOIN)
    //{
    //    licznik = LICZNIK;
    //    licznkiDynamit = LICZNIKDYNAMIT;
    //    licznkiNaprawiarka = LICZNIKNAPRAWIARKA;
    //    licznkiZasoby = LICZNIKZASOBY;
    //    licznkiCoin = LICZNIKCOIN;
    //}

    void Spawning(CoSpawnic coSpawnic, Vector3 pos)
    {
        Quaternion rot = Quaternion.Euler(0, 0, UnityEngine.Random.Range(1.0f, 360.0f));

        switch (coSpawnic)
        {
        case CoSpawnic.Score:
            PhotonNetwork.InstantiateSceneObject("Item_Exp", pos, rot, 0, null);
            //Instantiate(Food, pos, rot);
            break;

        case CoSpawnic.Coin:
            PhotonNetwork.InstantiateSceneObject("Item_Coin", pos, rot, 0, null);
            //Instantiate(Coin, pos, rot);
            break;

        case CoSpawnic.Dynamit:
            PhotonNetwork.InstantiateSceneObject("Item_Dynamite", pos, rot, 0, null);
            //Instantiate(Dynamite, pos, rot);
            break;

        case CoSpawnic.Naprawiarka:
            PhotonNetwork.InstantiateSceneObject("Item_Naprawka", pos, rot, 0, null);
            //Instantiate(Naprawka, pos, rot);
            break;

        case CoSpawnic.Zasoby:
            PhotonNetwork.InstantiateSceneObject("Item_Zasoby", pos, rot, 0, null);
            //Instantiate(Zasoby, pos, rot);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 12
0
    void RespawnZombieOnNetwork()
    {
        //debug
        if (respawnerSetting.zombiePrefebs == null)
        {
            Debug.LogError("<Color=Red><a>Missing</a></Color> respawnerSetting.zombiePrefebs is null", this);
            return;
        }

        if (ZombieCurrentAmount <= respawnerSetting.MaxZombieAmount)
        {
            GameObject newZombie = PhotonNetwork.InstantiateSceneObject(this.respawnerSetting.zombiePrefebs[Zoffest % respawnerSetting.zombiePrefebs.Length].name,
                                                                        respawnerSetting.respawnPlace.position,
                                                                        respawnerSetting.respawnPlace.rotation, 0, null);

            PhotonView zombiephotonView = newZombie.GetComponent <PhotonView>();

            photonView.RPC("SetNewZombie", PhotonTargets.All, zombiephotonView.viewID);

            ZombieCurrentAmount++;
            lastRespawnTime = Time.time;

            Zoffest++;
            if (Zoffest >= 6)
            {
                Zoffest = 0;
            }
        }


        //call RPC
    }
Ejemplo n.º 13
0
    public void LegendCardG()
    {
        // Prince Thorald leaves the game
        GameObject found = GameObject.Find("Prince");

        if (found == null)
        {
            found = GameObject.Find("Prince(Clone)");
        }
        found.GetPhotonView().RPC("Destroy", RpcTarget.AllBuffered);
        // add wardarks on space 26 and 27 (move twice at the end of the day)
        Vector3 w26 = GameBoardRegion.getCoordinates(26);
        Vector3 w27 = GameBoardRegion.getCoordinates(27);
        Dictionary <int, Vector3> wPositions = new Dictionary <int, Vector3>()
        {
            { 26, w26 },
            { 27, w27 }
        };
        GameObject m;

        foreach (KeyValuePair <int, Vector3> w in wPositions)
        {
            m = (GameObject)PhotonNetwork.InstantiateSceneObject("Wardrak", w.Value, Quaternion.identity);
            SceneManager.MoveGameObjectToScene(m, SceneManager.GetSceneByName("GameScene"));
            PhotonView v3 = m.GetPhotonView();
            v3.RPC("DontDestroy", RpcTarget.AllBuffered);
            v3.RPC("SetPosition", RpcTarget.AllBuffered, w.Key);
        }
    }
Ejemplo n.º 14
0
        void Update()
        {
            if (player != null && photonView.IsMine)
            {
                FollowTarget(player.GetComponent <Target>());
            }

            /*  //FIND PLAYER ROTATION AND ROTATE TOWARDS HIM
             * Vector3 targetDir = player.position - transform.position;
             * float step = rotationSpeed * Time.deltaTime;
             * Vector3 newDir = Vector3.RotateTowards(transform.forward, targetDir, step, 0.0f);
             * //RETREAT
             * if (Vector3.Distance(transform.position, player.position) <= retreatDistance)
             * {
             *    transform.position = Vector3.MoveTowards(transform.position, player.position, -speed * Time.deltaTime);
             *    transform.rotation = Quaternion.LookRotation(newDir);
             * }*/


            //SHOOT
            if (timeBetweenShots <= 0)
            {
                GameObject projectileClone;
                projectileClone  = PhotonNetwork.InstantiateSceneObject(this.projectile.name, firePoint.transform.position, this.transform.rotation) as GameObject;
                timeBetweenShots = attackSpeed;
                StartCoroutine(DestroyGameObject(projectileClone, 3f));
            }
            else
            {
                timeBetweenShots -= Time.deltaTime;
            }
        }
        private IEnumerator SpawnAsteroid()
        {
            while (true)
            {
                yield return(new WaitForSeconds(Random.Range(AsteroidsGame.ASTEROIDS_MIN_SPAWN_TIME, AsteroidsGame.ASTEROIDS_MAX_SPAWN_TIME)));

                Vector2 direction = Random.insideUnitCircle;
                Vector3 position  = Vector3.zero;

                if (Mathf.Abs(direction.x) > Mathf.Abs(direction.y))
                {
                    // Make it appear on the left/right side
                    position = new Vector3(Mathf.Sign(direction.x) * Camera.main.orthographicSize * Camera.main.aspect, 0, direction.y * Camera.main.orthographicSize);
                }
                else
                {
                    // Make it appear on the top/bottom
                    position = new Vector3(direction.x * Camera.main.orthographicSize * Camera.main.aspect, 0, Mathf.Sign(direction.y) * Camera.main.orthographicSize);
                }

                // Offset slightly so we are not out of screen at creation time (as it would destroy the asteroid right away)
                position -= position.normalized * 0.1f;


                Vector3  force             = -position.normalized * 1000.0f;
                Vector3  torque            = Random.insideUnitSphere * Random.Range(500.0f, 1500.0f);
                object[] instantiationData = { force, torque, true };

                PhotonNetwork.InstantiateSceneObject("BigAsteroid", position, Quaternion.Euler(Random.value * 360.0f, Random.value * 360.0f, Random.value * 360.0f), 0, instantiationData);
            }
        }
Ejemplo n.º 16
0
 public void AIControl()
 {
     /* if (portal==null&&ObjectsAI.Count==0)
      * {
      *   if (ObjectsAI)
      *   {
      *
      *   }
      *   portal=Instantiate(portalOBJ);
      * }*/
     if (ObjectsAI.Count != 0)
     {
         foreach (var item in ObjectsAI)
         {
             if (item == null)
             {
                 ObjectsAI.Remove(item);
             }
             return;
         }
     }
     else
     {
         if (spawnedBoss < 1)
         {
             if (!PhotonNetwork.isMasterClient)
             {
                 return;
             }
             PhotonNetwork.InstantiateSceneObject(Boss[Random.Range(0, 2)].name, new Vector2(91.56f, 15), UnityEngine.Quaternion.identity, 0, null);
             spawnedBoss++;
         }
     }
 }
Ejemplo n.º 17
0
    void spawnPenguin()
    {
        int PEN = Random.Range(1, 10);

        //Instantiate random
        //GameObject penguin = Instantiate(penguins);
        //if (PhotonNetwork.isMasterClient == true)
        //{
        //if (!PhotonNetwork.IsMasterClient)
        //return;
        for (var i = 0; i < PEN; i++)
        {
            if (PhotonNetwork.IsMasterClient)
            {
                Vector3 origin      = transform.position;
                Vector3 range       = transform.localScale * 5.0f;
                Vector3 randomRange = new Vector3(Random.Range(-range.x, range.x),
                                                  Random.Range(1, 1),
                                                  Random.Range(-range.z, range.z));

                Vector3 randomCoordinate = origin + randomRange;

                float randomRotation = Random.Range(-180, 180);
                float randomSize     = Random.Range(0.6f, 1);

                GameObject peng = PhotonNetwork.InstantiateSceneObject("anamatedPenguin", randomCoordinate, Quaternion.Euler(0, randomRotation, 0), 0, null);
                peng.transform.localScale = new Vector3(randomSize, randomSize, randomSize);
            }

            //penguin.transform.position = transform.position;
            //penguin.transform.parent = transform;
            // }
        }
    }
Ejemplo n.º 18
0
    public void Attack()
    {
        if (!PhotonNetwork.isMasterClient)
        {
            return;
        }
        if (numMonsters < maxMonsterSpawn)
        {
            GameObject newMonster = PhotonNetwork.InstantiateSceneObject(monster.name, spawnPoint.position, Quaternion.identity, 0, null);
            newMonster.GetComponent <Enemy> ().SetTowerParent(gameObject);
            numMonsters++;
        }

        bulletCooldown += Time.deltaTime;

        // If cooldown has passed and target is not tower's owner then attack
        if (bulletCooldown >= bulletCastTime && !IsOwner(target.gameObject))
        {
            //Vector3 direction = Utils.isoProjectile(Utils.isoVector3(target.transform.position - shootPointSE.position));
            Vector3 direction = target.transform.position - shootPointE.position;
            direction.Normalize();
            GameObject bulletClone = PhotonNetwork.InstantiateSceneObject(bullet.name,
                                                                          shootPointE.transform.position,
                                                                          Quaternion.Euler(direction), 0, null);
            bulletClone.transform.position = new Vector3(shootPointE.transform.position.x,
                                                         shootPointE.transform.position.y,
                                                         target.transform.position.z);
            bulletClone.GetComponent <Rigidbody2D> ().velocity = direction * bulletSpeed;
            bulletCooldown = 0;
            StartCoroutine(Utils.NetworkDestroy(bulletClone, bulletLifetime));
        }
    }
Ejemplo n.º 19
0
 static public void CreateDefaultTimer()
 {
     if (PhotonNetwork.IsMasterClient && single == null)
     {
         PhotonNetwork.InstantiateSceneObject("TimerNet", Vector3.zero, Quaternion.identity);
     }
 }
Ejemplo n.º 20
0
        /**
         * Générer les ressources sur la carte aléatoirement
         * @param void
         * @return void
         * @author Vincent Gagnon
         */
        void GenererRessources()
        {
            foreach (Player p in PhotonNetwork.PlayerList)
            {
                nbJoueurConnecte++;
            }

            // Générer aléatoirement l'emplacement du bois
            Shuffle(aSpawnerBois);

            for (int iBois = 0; iBois < 4; iBois++)
            {
                GameObject oCloneBois = PhotonNetwork.InstantiateSceneObject("bois", aSpawnerBois[iBois].transform.position, Quaternion.Euler(aSpawnerBois[iBois].transform.eulerAngles));
                oCloneBois.transform.parent = aSpawnerBois[iBois].transform;
            }

            // Générer aléatoirement l'emplacement du fer
            Shuffle(aSpawnerFer);

            for (int iFer = 0; iFer < 5; iFer++)
            {
                GameObject oCloneFer = PhotonNetwork.InstantiateSceneObject("fer", aSpawnerFer[iFer].transform.position, Quaternion.Euler(aSpawnerFer[iFer].transform.eulerAngles));
                oCloneFer.transform.parent = aSpawnerFer[iFer].transform;
            }

            // Générer aléatoirement l'emplacement du cuir
            Shuffle(aSpawnerCuir);

            for (int iCuir = 0; iCuir < 4; iCuir++)
            {
                GameObject oCloneCuir = PhotonNetwork.InstantiateSceneObject("cuir", aSpawnerCuir[iCuir].transform.position, Quaternion.Euler(aSpawnerCuir[iCuir].transform.eulerAngles));
                oCloneCuir.transform.parent = aSpawnerCuir[iCuir].transform;
            }
        }
Ejemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        PV = GetComponent <PhotonView>();

        if (PhotonNetwork.IsMasterClient)
        {
            if (PV.IsMine)
            {
                myAvatar = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "PlayerAvatar"),
                                                     GameSetup.GS.spawnPoints[0].position, GameSetup.GS.spawnPoints[0].rotation, 0);
                myAvatar.tag = "Player1";
                myAvatar.GetComponent <PlayerMouvement>().xMaxLimit = -0.5f;
                myAvatar.GetComponent <PlayerMouvement>().xMinLimit = -4f;
                myAvatar.GetComponent <PlayerMouvement>().zMaxLimit = 3.5f;
                myAvatar.GetComponent <PlayerMouvement>().zMinLimit = -3.5f;
                PhotonNetwork.InstantiateSceneObject(Path.Combine("PhotonPrefabs", "PhotonBotP1"), GameSetup.GS.spawnBotP1.transform.position, GameSetup.GS.spawnBotP1.transform.rotation, 0);
                PhotonNetwork.InstantiateSceneObject(Path.Combine("PhotonPrefabs", "PhotonBotP2"), GameSetup.GS.spawnBotP2.transform.position, GameSetup.GS.spawnBotP2.transform.rotation, 0);
            }
        }
        else
        {
            if (PV.IsMine)
            {
                myAvatar = PhotonNetwork.Instantiate(Path.Combine("PhotonPrefabs", "PlayerAvatar"),
                                                     GameSetup.GS.spawnPoints[1].position, GameSetup.GS.spawnPoints[1].rotation, 0);
                myAvatar.tag = "Player2";
                myAvatar.GetComponent <PlayerMouvement>().xMaxLimit = 4f;
                myAvatar.GetComponent <PlayerMouvement>().xMinLimit = 0.5f;
                myAvatar.GetComponent <PlayerMouvement>().zMaxLimit = 3.5f;
                myAvatar.GetComponent <PlayerMouvement>().zMinLimit = -3.5f;
            }
        }
    }
Ejemplo n.º 22
0
    void SpawnMonsters()
    {
        Spawn      monsterSpawn = s[1];
        GameObject monster      = (GameObject)PhotonNetwork.InstantiateSceneObject("Monster", monsterSpawn.transform.position, monsterSpawn.transform.rotation, 0);

        monster.GetComponent <MonsterAI>().enabled = true;
    }
Ejemplo n.º 23
0
    void Spawn()
    {
        // Do things on the master client - he is our bitch
        print("Making monsters");
        GameObject[] allPlayers = GameObject.FindGameObjectsWithTag("Player");
        //spawn a monster around each player
        foreach (GameObject player in allPlayers)
        {
            for (int i = 0; i < MONSTERS_TO_SPAWN; i++)
            {
                Vector3 randPos = Random.onUnitSphere * MIN_SPAWN_DISTANCE + Random.insideUnitSphere * (MAX_SPAWN_DISTANCE - MIN_SPAWN_DISTANCE);
                randPos.y = MAX_SPAWN_DISTANCE * 1.25F;                 //so the monster doesn't spawn underground
                Vector3 spawnPos = new Vector3(player.transform.position.x + randPos.x, player.transform.position.y + randPos.y, player.transform.position.z + randPos.z);

                GameObject newMon = PhotonNetwork.InstantiateSceneObject("realMonsterPrefab", spawnPos, Quaternion.Euler(0, 0, 0), 0, null);

                monstersLeft++;
                //place monster on the ground after spawning
                if (Physics.Raycast(newMon.transform.position, Vector3.down, out groundHit, Mathf.Infinity))
                {
                    print("Replaced y: " + groundHit.point.y);
                    newMon.transform.position = new Vector3(spawnPos.x, groundHit.point.y + 1.5F, spawnPos.z);
                }
                else
                {
                    //we're like ALL the way underground?
                    //oh gosh I hope we aren't inside the ground
                    PhotonNetwork.Destroy(newMon);
                    //Destroy(newMon); //screw him then.
                    monstersLeft--;
                }
            }     //end of for loop
        }         //end of for each
    }
Ejemplo n.º 24
0
    private void Start()
    {
        if (!Y3P1.Player.localPlayerObject && playerPrefab)
        {
            PhotonNetwork.Instantiate(playerPrefab.name, new Vector3(0, 0.1f, 0), Quaternion.identity);
        }

        if (PhotonNetwork.IsMasterClient)
        {
            if (!FindObjectOfType <BountyManager>())
            {
                PhotonNetwork.InstantiateSceneObject(bountyManagerPrefab.name, Vector3.zero, Quaternion.identity);
            }

            if (!FindObjectOfType <ProjectileManager>())
            {
                PhotonNetwork.InstantiateSceneObject(projectileManagerPrefab.name, Vector3.zero, Quaternion.identity);
            }

            if (!FindObjectOfType <NotificationManager>())
            {
                PhotonNetwork.InstantiateSceneObject(notificationManagerPrefab.name, Vector3.zero, Quaternion.identity);
            }

            //if (!FindObjectOfType<DroppedItemManager>())
            //{
            //    PhotonNetwork.InstantiateSceneObject(droppedItemManagerPrefab.name, Vector3.zero, Quaternion.identity);
            //}
        }
    }
Ejemplo n.º 25
0
 void Start()
 {
     if (PhotonNetwork.IsMasterClient)
     {
         PhotonNetwork.InstantiateSceneObject(prefab, transform.position, transform.rotation, 0);
     }
 }
    // level up
    public void LevelUp()
    {
        // play a level up particle effect and sound
        Quaternion levelUpRot = Quaternion.Euler(-90, 0, 0);
        Vector3    levelUpPos = new Vector3(transform.position.x, 0f, transform.position.z);

        PhotonNetwork.InstantiateSceneObject("LevelUp", levelUpPos, levelUpRot, 0);

        if (level != 0)
        {
            transform.GetComponent <PhotonView>().RPC("playSound", PhotonTargets.AllBuffered, 10, 1f);
        }

        level += 1;
        if (level == 4)
        {
            ultimateSkillPoints += 1;
        }
        else
        {
            skillPoints += 1;
        }
        damage              = 8 + level * 2f;
        jumpForce           = 600f;
        attackCooldownDelay = 1.1f;

        /* Sets Character Maximum Health for new Level */
        this.maxHealth     = this.vitalLevelHP[this.level - 1];
        this.currentHealth = this.maxHealth;

        /* Sets Character Maximum Experience for new level */
        this.maxEXP     = this.vitalLevelEXP[this.level - 1];
        this.currentEXP = 0;
    }
Ejemplo n.º 27
0
 private void Start()
 {
     if (PhotonNetwork.IsMasterClient)
     {
         PhotonNetwork.InstantiateSceneObject(spawnable.name, transform.position, Quaternion.identity);
     }
 }
Ejemplo n.º 28
0
 private void RequestSceneObjectInstantiate(string prefabName, Vector3 position)
 {
     if (PhotonNetwork.isMasterClient)
     {
         PhotonNetwork.InstantiateSceneObject(prefabName, position, Quaternion.identity, 0, null);
     }
 }
 // spawn the keys and chests in the puzzle rooms
 void SpawnKeysAndChests()
 {
     // spawn each key and chest
     if (PhotonNetwork.isMasterClient)
     {
         List <float> keyLocations   = mazeInstance.getKeySpawns();
         List <float> chestLocations = mazeInstance.getChestSpawns();
         for (int i = 0; i < 6; i += 2)
         {
             // if the puzzle room is either the ball/target room or the boss room
             // then dont spawn the keys until the room is passed
             if (activePuzzleTypes[i / 2] == 3 || activePuzzleTypes[i / 2] == 5)
             {
             }
             else
             {
                 Vector3    keyPos = new Vector3(keyLocations[i], 1, keyLocations[i + 1]);
                 Quaternion keyRot = new Quaternion(0f, 0f, 0f, 0f);
                 PhotonNetwork.InstantiateSceneObject("Key", keyPos, keyRot, 0);
             }
             Vector3    chestPos = new Vector3(chestLocations[i], 0.35f, chestLocations[i + 1]);
             Quaternion chestRot = new Quaternion(0f, 0f, 0f, 0f);
             GameObject chest    = (GameObject)PhotonNetwork.InstantiateSceneObject("Chest", chestPos, chestRot, 0);
             Chest      newChest = chest.GetComponent <Chest>();
             newChest.setWhichPieceInside((i / 2) + 1);
         }
     }
 }
Ejemplo n.º 30
0
 public void CreateSpawnSpotHoles()
 {
     for (int i = 0; i < spawnSpots.GetLength(0); i++)
     {
         PhotonNetwork.InstantiateSceneObject("SpawnHoles", spawnSpots[i].transform.position, Quaternion.identity, 0, null);
     }
 }