Пример #1
0
 private void Start()
 {
     EditorSpawns._isSpawning      = false;
     EditorSpawns._itemSpawn       = ((GameObject)Object.Instantiate(Resources.Load("Edit/Item"))).transform;
     EditorSpawns.itemSpawn.name   = "Item Spawn";
     EditorSpawns.itemSpawn.parent = Level.editing;
     EditorSpawns.itemSpawn.gameObject.SetActive(false);
     if ((int)EditorSpawns.selectedItem < LevelItems.tables.Count)
     {
         EditorSpawns.itemSpawn.GetComponent <Renderer>().material.color = LevelItems.tables[(int)EditorSpawns.selectedItem].color;
     }
     EditorSpawns._playerSpawn       = ((GameObject)Object.Instantiate(Resources.Load("Edit/Player"))).transform;
     EditorSpawns.playerSpawn.name   = "Player Spawn";
     EditorSpawns.playerSpawn.parent = Level.editing;
     EditorSpawns.playerSpawn.gameObject.SetActive(false);
     EditorSpawns._playerSpawnAlt       = ((GameObject)Object.Instantiate(Resources.Load("Edit/Player_Alt"))).transform;
     EditorSpawns.playerSpawnAlt.name   = "Player Spawn Alt";
     EditorSpawns.playerSpawnAlt.parent = Level.editing;
     EditorSpawns.playerSpawnAlt.gameObject.SetActive(false);
     EditorSpawns._zombieSpawn       = ((GameObject)Object.Instantiate(Resources.Load("Edit/Zombie"))).transform;
     EditorSpawns.zombieSpawn.name   = "Zombie Spawn";
     EditorSpawns.zombieSpawn.parent = Level.editing;
     EditorSpawns.zombieSpawn.gameObject.SetActive(false);
     if ((int)EditorSpawns.selectedZombie < LevelZombies.tables.Count)
     {
         EditorSpawns.zombieSpawn.GetComponent <Renderer>().material.color = LevelZombies.tables[(int)EditorSpawns.selectedZombie].color;
     }
     EditorSpawns._vehicleSpawn       = ((GameObject)Object.Instantiate(Resources.Load("Edit/Vehicle"))).transform;
     EditorSpawns.vehicleSpawn.name   = "Vehicle Spawn";
     EditorSpawns.vehicleSpawn.parent = Level.editing;
     EditorSpawns.vehicleSpawn.gameObject.SetActive(false);
     if ((int)EditorSpawns.selectedVehicle < LevelVehicles.tables.Count)
     {
         EditorSpawns.vehicleSpawn.GetComponent <Renderer>().material.color = LevelVehicles.tables[(int)EditorSpawns.selectedVehicle].color;
         EditorSpawns.vehicleSpawn.FindChild("Arrow").GetComponent <Renderer>().material.color = LevelVehicles.tables[(int)EditorSpawns.selectedVehicle].color;
     }
     EditorSpawns._animalSpawn        = ((GameObject)Object.Instantiate(Resources.Load("Edit/Animal"))).transform;
     EditorSpawns._animalSpawn.name   = "Animal Spawn";
     EditorSpawns._animalSpawn.parent = Level.editing;
     EditorSpawns._animalSpawn.gameObject.SetActive(false);
     if ((int)EditorSpawns.selectedAnimal < LevelAnimals.tables.Count)
     {
         EditorSpawns.animalSpawn.GetComponent <Renderer>().material.color = LevelAnimals.tables[(int)EditorSpawns.selectedAnimal].color;
     }
     EditorSpawns._remove       = ((GameObject)Object.Instantiate(Resources.Load("Edit/Remove"))).transform;
     EditorSpawns.remove.name   = "Remove";
     EditorSpawns.remove.parent = Level.editing;
     EditorSpawns.remove.gameObject.SetActive(false);
     EditorSpawns.spawnMode = ESpawnMode.ADD_ITEM;
     EditorSpawns.load();
 }
Пример #2
0
 private void Update()
 {
     if (!EditorSpawns.isSpawning)
     {
         return;
     }
     if (!EditorInteract.isFlying && GUIUtility.hotControl == 0)
     {
         if (Input.GetKeyDown(ControlsSettings.tool_0))
         {
             if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_RESOURCE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ITEM;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_PLAYER;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ZOMBIE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_VEHICLE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ANIMAL;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.tool_1))
         {
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_RESOURCE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_RESOURCE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ITEM;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_PLAYER;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ZOMBIE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_VEHICLE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ANIMAL;
             }
         }
         if (EditorInteract.worldHit.transform != null)
         {
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 EditorSpawns.itemSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 EditorSpawns.playerSpawn.position    = EditorInteract.worldHit.point;
                 EditorSpawns.playerSpawnAlt.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 EditorSpawns.zombieSpawn.position = EditorInteract.worldHit.point + Vector3.up;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 EditorSpawns.vehicleSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 EditorSpawns.animalSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM || EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 EditorSpawns.remove.position = EditorInteract.worldHit.point;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.primary) && EditorInteract.worldHit.transform != null)
         {
             Vector3 point = EditorInteract.worldHit.point;
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_RESOURCE)
             {
                 if ((int)EditorSpawns.selectedResource < LevelGround.resources.Length)
                 {
                     LevelGround.addSpawn(point, EditorSpawns.selectedResource, false);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE)
             {
                 LevelGround.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 if ((int)EditorSpawns.selectedItem < LevelItems.tables.Count)
                 {
                     LevelItems.addSpawn(point);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM)
             {
                 LevelItems.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 LevelPlayers.addSpawn(point, EditorSpawns.rotation, EditorSpawns.selectedAlt);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER)
             {
                 LevelPlayers.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 if ((int)EditorSpawns.selectedZombie < LevelZombies.tables.Count)
                 {
                     LevelZombies.addSpawn(point);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE)
             {
                 LevelZombies.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 LevelVehicles.addSpawn(point, EditorSpawns.rotation);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE)
             {
                 LevelVehicles.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 LevelAnimals.addSpawn(point);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 LevelAnimals.removeSpawn(point, (float)EditorSpawns.radius);
             }
         }
     }
 }