Inheritance: MonoBehaviour
Example #1
0
    public void SpawnWave()
    {
        if (currentWaveIndex >= Waves.Length)
        {
            //Debug.LogWarning("No Waves Left. You Win!");
            //StartCoroutine(GameManager.Instance.EndGame());
            OnOutOfWaves.Invoke();
            return;
        }

        if (currentWaveIndex > 0)
        {
            SoundManager.Instance.PlaySoundEffect(SoundEffect.NextWave);
            OnWaveSpawned.Invoke();
        }

        activeMobs = Waves[currentWaveIndex].NumberOfMobs;

        for (int i = 0; i < Waves[currentWaveIndex].NumberOfMobs; i++)
        {
            Spawnpoint spawnpoint = selectRandomSpawnpoint();
            GameObject mob        = Instantiate(selectRandomMob(),
                                                spawnpoint.transform.position, Quaternion.identity);

            mob.GetComponent <NPCController>().waypoints = findClosestWayPoints(mob.transform);

            CharacterStats stats       = mob.GetComponent <CharacterStats>();
            MobWave        currentWave = Waves[currentWaveIndex];

            stats.SetInitialHealth(currentWave.MobHealth);
            stats.SetInitialResistance(currentWave.MobResistance);
            stats.SetInitialDamage(currentWave.MobDamage);
        }
    }
Example #2
0
 public void calculateIslandToDecoMapping()
 {
     this.m_islandToDecoMap.Clear();
     if (this.DecoSpawnpoints.Count != 0)
     {
         if ((this.DecoSpawnpoints.Count > 0) && (this.IslandSpawnpoints.Count == 0))
         {
             Debug.LogError("Decos require at least one island spawnpoint.");
         }
         else
         {
             for (int i = 0; i < this.IslandSpawnpoints.Count; i++)
             {
                 this.m_islandToDecoMap.Add(this.IslandSpawnpoints[i], new List <MarkerSpawnPointDeco>());
             }
             for (int j = 0; j < this.DecoSpawnpoints.Count; j++)
             {
                 MarkerSpawnPointDeco item = this.DecoSpawnpoints[j];
                 float      maxValue       = float.MaxValue;
                 Spawnpoint spawnpoint     = null;
                 for (int k = 0; k < this.IslandSpawnpoints.Count; k++)
                 {
                     Spawnpoint spawnpoint2 = this.IslandSpawnpoints[k];
                     float      num5        = Vector3.Distance(item.Tm.position, spawnpoint2.WorldPt);
                     if (num5 < maxValue)
                     {
                         spawnpoint = spawnpoint2;
                         maxValue   = num5;
                     }
                 }
                 this.m_islandToDecoMap[spawnpoint].Add(item);
             }
         }
     }
 }
Example #3
0
    // Spawn AIs and a player using all spawnpoints in the scene
    private void Spawn()
    {
        spawnPoints      = GameObject.FindGameObjectsWithTag("Spawnpoint");
        circlesRemaining = 0;
        bool playerHasBeenSpawned = false;

        foreach (GameObject spawn in spawnPoints)
        {
            Spawnpoint script = spawn.GetComponent <Spawnpoint>();
            if (script.canSpawnAI && script.canSpawnPlayer)             // Some spawnpoints are allowed to spawn AIs and players...
            {
                int AIorPlayer = Random.Range(0, 2);
                if (playerHasBeenSpawned || AIorPlayer == 0)
                {
                    int prefabToSpawn = Random.Range(0, aiPrefabs.Length);
                    GameObject.Instantiate(aiPrefabs[prefabToSpawn], spawn.transform.position, spawn.transform.rotation);
                }
                else
                {
                    GameObject.Instantiate(playerPrefab, spawn.transform.position, spawn.transform.rotation);
                    playerHasBeenSpawned = true;
                }
            }
            else if (script.canSpawnAI)             // ...some can only spawn AIs...
            {
                int prefabToSpawn = Random.Range(0, aiPrefabs.Length);
                GameObject.Instantiate(aiPrefabs[prefabToSpawn], spawn.transform.position, spawn.transform.rotation);
            }
            else if (script.canSpawnPlayer)             // ...and some can only spawn players...
            {
                GameObject.Instantiate(playerPrefab, spawn.transform.position, spawn.transform.rotation);
            }
            circlesRemaining++;
        }
    }
Example #4
0
 public void SetRespawn(Checkpoint checkpoint)
 {
     if (currentCheckpoint != null)
     {
         currentCheckpoint.SetActived(false);
     }
     currentCheckpoint = checkpoint;
     CurrentSpawn      = currentCheckpoint.GetSpawnpoint();
 }
Example #5
0
 public void ShuffleSpawnpoints()
 {
     for (int i = 0; i < spawnpoints.Length - 1; i++)
     {
         int rnd = Random.Range(i, spawnpoints.Length);
         tmp = spawnpoints[rnd];
         spawnpoints[rnd] = spawnpoints[i];
         spawnpoints[i]   = tmp;
     }
 }
Example #6
0
            public override void Execute(Timeline timeline)
            {
                Spawnpoint spawn = timeline.GetSpawnpoint(spawnpoint);
                Patient    p     = Instantiate(timeline.patientPrefab);

                p.transform.position = spawn.transform.position;
                patient.skinMaterial = (timeline.patientSkins.Length == 0) ? null :
                                       timeline.patientSkins[UnityEngine.Random.Range(0, timeline.patientSkins.Length)];
                p.Setup(patient);
                p.AddDespawnAction(() => timeline.EventEnded(this));
            }
Example #7
0
        public void Initialize(string file)
        {
            fileLine = File.ReadAllLines(file);

            // Parse Spawnpoint
            string[] spLine = fileLine[counter].Split(' ');
            spawnPoint = new Spawnpoint(new Vector2(int.Parse(spLine[0]), int.Parse(spLine[1])));

            InitializeEvents();
            InitializeEnemies();
            InitializeTileMap();
        }
Example #8
0
    // Start is called before the first frame update
    void Start()
    {
        currentLife = maximumLife;

        generateWeaknessTimer = Random.Range(generateWeaknessDuration, 8);

        attackPlayerScript = GetComponentInParent <AttackPlayer>();
        spawnPoint         = GameObject.Find("MasterSpawner").GetComponent <Spawnpoint>();
        playerStats        = GameObject.Find("GameManager").GetComponent <PlayerStats>();
        enemyWeakness      = GetComponentInChildren <EnemyWeakness>();
        AddWeaknessToEnemy();
    }
Example #9
0
    public override void Awake()
    {
        base.Awake();
        if (curSpawnPoint == null)
        {
            curSpawnPoint = this;
        }

        if (spawnPosition == null)
        {
            Debug.Log("Fatal warning! Spawnpoint " + gameObject.name + " has no spawn position!!");
        }
    }
Example #10
0
        public override void grantReward(Player player, bool shouldSend)
        {
            if (!Provider.isServer)
            {
                return;
            }
            Spawnpoint spawnpoint = SpawnpointSystem.getSpawnpoint(this.spawnpoint);

            if (spawnpoint == null)
            {
                Debug.LogError("Failed to find NPC teleport reward spawnpoint: " + this.spawnpoint);
                return;
            }
            player.sendTeleport(spawnpoint.transform.position, MeasurementTool.angleToByte(spawnpoint.transform.rotation.eulerAngles.y));
        }
Example #11
0
        // Token: 0x06001C35 RID: 7221 RVA: 0x000996D8 File Offset: 0x00097AD8
        public override void grantReward(Player player, bool shouldSend)
        {
            if (!Provider.isServer)
            {
                return;
            }
            Spawnpoint spawnpoint = SpawnpointSystem.getSpawnpoint(this.spawnpoint);

            if (spawnpoint == null)
            {
                Debug.LogError("Failed to find NPC vehicle reward spawnpoint: " + this.spawnpoint);
                return;
            }
            VehicleManager.spawnVehicle(this.id, spawnpoint.transform.position, spawnpoint.transform.rotation);
        }
Example #12
0
 public void ResetSpawnpoints()
 {
     foreach (GameObject spawnpoint in ingredientSpawnPoints)
     {
         Spawnpoint spawnScript = spawnpoint.GetComponent <Spawnpoint>();
         spawnScript.isAvailable = true;
         if (spawnpoint.transform.childCount > 0)
         {
             for (int i = spawnpoint.transform.childCount; i >= 0; i--)
             {
                 Destroy(spawnpoint.transform.GetChild(i).gameObject);
             }
         }
     }
 }
Example #13
0
        public Spawnpoint getClosestCharacterSpawnpoint(CharacterInstance refCharacter)
        {
            Spawnpoint spawnpoint = null;
            float      maxValue   = float.MaxValue;

            for (int i = 0; i < this.CharacterSpawnpoints.Count; i++)
            {
                Spawnpoint spawnpoint2 = this.CharacterSpawnpoints[i];
                float      num3        = Vector3.Distance(spawnpoint2.WorldPt, refCharacter.PhysicsBody.Transform.position);
                if (num3 < maxValue)
                {
                    spawnpoint = spawnpoint2;
                    maxValue   = num3;
                }
            }
            return(spawnpoint);
        }
Example #14
0
        public Spawnpoint getClosestIslandSpawnpoint(Vector3 worldPt)
        {
            Spawnpoint spawnpoint = null;
            float      maxValue   = float.MaxValue;

            for (int i = 0; i < this.IslandSpawnpoints.Count; i++)
            {
                Spawnpoint spawnpoint2 = this.IslandSpawnpoints[i];
                float      num3        = Vector3.Distance(spawnpoint2.WorldPt, worldPt);
                if (num3 < maxValue)
                {
                    spawnpoint = spawnpoint2;
                    maxValue   = num3;
                }
            }
            return(spawnpoint);
        }
Example #15
0
    public GameObject SelectRandomAvailableSpawnPoint()
    {
        int spawnCount = ingredientSpawnPoints.Count;

        for (int i = 0; i < 100; i++)
        {
            int randomIndex = Random.Range(0, spawnCount - 1);;

            GameObject randomSpawnpoint = ingredientSpawnPoints[randomIndex];
            Spawnpoint spawnScript      = randomSpawnpoint.GetComponent <Spawnpoint>();
            if (spawnScript.isAvailable)
            {
                spawnScript.isAvailable = false;
                return(randomSpawnpoint);
            }
        }
        Debug.Log("no spawnpoint found");
        return(null);
    }
Example #16
0
        private void SpawnVehicles()
        {
            for (int i = 0; i < racers.Count; i++)
            {
                RacePlayer player     = racers[i];
                Spawnpoint spawnpoint = spawnpoints[i];

                Vehicle vehicle = new Vehicle(VehicleModel.FromId(spawnpoint.VehicleModel), spawnpoint.Position);
                player.Vehicle = vehicle;

                vehicle.FaceElement(checkpoints.FirstOrDefault());
                vehicle.OnExplode += (BaseVehicle source, OnExplodeEventArgs eventArgs) =>
                {
                    DisqualifyPlayer(player);
                };
                vehicle.OnStartExit += (BaseVehicle source, OnStartExitEventArgs eventArgs) =>
                {
                    Event.Cancel();
                };
            }
        }
Example #17
0
 void Start()
 {
     rend       = GetComponent <SpriteRenderer>();
     spawnpoint = GetComponentInChildren <Spawnpoint>();
 }
Example #18
0
    public void MapChange(string name, XmlGroup map)
    {
        EndRound();

        var round = new Round();

        #region Objectives
        foreach (var element in map.getElementsByType("objective"))
        {
            var obj = new Objective();

            if (element.hasElementData("id"))
            {
                obj.Id = element.getElementData <int>("id");
            }

            obj.Position = new Vector3(element.getElementData <float>("posX"),
                                       element.getElementData <float>("posY"),
                                       element.getElementData <float>("posZ"));

            if (element.hasElementData("range"))
            {
                obj.Range = element.getElementData <float>("range");
            }

            obj.name = element.getElementData <string>("name");

            if (element.hasElementData("timer"))
            {
                obj.Timer = element.getElementData <int>("timer");
            }

            if (element.hasElementData("required"))
            {
                var listStr = element.getElementData <string>("required");
                obj.RequiredObjectives =
                    listStr.Split(',').Select(id => int.Parse(id, CultureInfo.InvariantCulture)).ToList();
            }

            round.Objectives.Add(obj);
        }
        #endregion

        #region Spawnpoints

        foreach (var element in map.getElementsByType("spawnpoint"))
        {
            var sp = new Spawnpoint();

            sp.Team    = element.getElementData <int>("team");
            sp.Heading = element.getElementData <float>("heading");

            sp.Position = new Vector3(element.getElementData <float>("posX"),
                                      element.getElementData <float>("posY"),
                                      element.getElementData <float>("posZ"));

            sp.Skins =
                element.getElementData <string>("skins")
                .Split(',')
                .Select(s => API.pedNameToModel(s))
                .ToArray();

            var guns =
                element.getElementData <string>("weapons")
                .Split(',')
                .Select(w => API.weaponNameToModel(w));
            var ammos =
                element.getElementData <string>("ammo")
                .Split(',')
                .Select(w => int.Parse(w, CultureInfo.InvariantCulture));

            sp.Weapons = guns.ToArray();
            sp.Ammo    = ammos.ToArray();

            if (element.hasElementData("objectives"))
            {
                var objectives =
                    element.getElementData <string>("objectives")
                    .Split(',')
                    .Select(w => int.Parse(w, CultureInfo.InvariantCulture));

                sp.RequiredObjectives = objectives.ToArray();
            }

            round.Spawnpoints.Add(sp);
        }
        #endregion

        StartRound(round);
    }
Example #19
0
    // Use this for initialization
    void Start()
    {
        topLeft = new Spawnpoint(topLeftPipe.gameObject, 1, -1);
        topRight = new Spawnpoint(topRightPipe.gameObject, -1, -1);
        bottomLeft = new Spawnpoint(bottomLeftPipe.gameObject, -1, 1);
        bottomRight = new Spawnpoint(bottomRightPipe.gameObject, 1, 1);

        //let it be.
        //if (canGenerate) AddToStack(baseNME, true);
    }
Example #20
0
 void Start()
 {
     spawnerInfo = GameObject.Find("MasterSpawner").GetComponent <Spawnpoint>();
     playerStats = GameObject.Find("GameManager").GetComponent <PlayerStats>();
     keyInfoUI   = gameObject.GetComponentsInChildren <Text>();
 }
 void Start()
 {
     script        = GameObject.Find("SceneManager").GetComponent <Spawnpoint>();
     checkpointGot = false;
 }
Example #22
0
 public void Set_Spawn()
 {
     curSpawnPoint = this;
 }
Example #23
0
 public List <MarkerSpawnPointDeco> getDecoSpawnpointMarkersForIsland(Spawnpoint islandSpawnpoint)
 {
     return(this.m_islandToDecoMap[islandSpawnpoint]);
 }