Пример #1
0
    void ParseMap(string map)
    {
        lastMap = map;

        var maps = map.Split('|');

        int i = 1;

        float time = 0;

        for (; i < maps.Length; i += 5)
        {
            var b = new WaveElement(maps[i + 0], int.Parse(maps[i + 1]), float.Parse(maps[i + 2]), float.Parse(maps[i + 3]), int.Parse(maps[i + 4]));

            if (lastTime < time + b.startTime + b.deltaTime * b.count)
            {
                lastTime = time + b.startTime + b.deltaTime * b.count;
            }

            if (waves.ContainsKey(time + b.startTime))
            {
                waves[time + b.startTime].Add(b);
            }
            else
            {
                waves.Add(time + b.startTime, new List <WaveElement> ());
                waves[time + b.startTime].Add(b);
            }

            if (b.type == "-1")
            {
                time += b.startTime;
            }
        }
    }
Пример #2
0
 void InitWave()
 {
     for (int x = 0; x < wave.GetLength(0); x++)
     {
         for (int y = 0; y < wave.GetLength(1); y++)
         {
             wave[x, y] = new WaveElement(possibleTiles);
         }
     }
 }
Пример #3
0
    /// <summary>
    /// Selects a spawnpoint and spawn the an enemy
    /// </summary>
    /// <param name="element">The element to spawn</param>
    private void spawn(WaveElement element)
    {
        Vector3 startPoint = (spawnAtObject) ? spawnObject.transform.position : spawnlocation;

        xpos = addRandom(startPoint.x, randomSpawnPosition.x);
        ypos = addRandom(startPoint.y, randomSpawnPosition.y);
        zpos = addRandom(startPoint.z, randomSpawnPosition.z);

        startPoint = new Vector3(xpos, ypos, zpos);

        alive.Add(Instantiate((element.randomEnemy) ? element.enemySet.GetEnemy() : element.enemy, startPoint, new Quaternion(0, 0, 0, 0)));
    }
Пример #4
0
    private void Spawn()
    {
        m_currentIndex++;
        WaveElement element = m_waveElements[m_currentIndex];

        // Get Zone
        SpawnZone zone = SpawnZoneConfiguration.Instance.Zones.Find(z => z.Tag == element.SpawnZone);

        // Spawn object
        m_lastSpawned = Instantiate(element.UnitPrefab, zone.GetRandomPointInZone(), Quaternion.identity);

        m_lastSpawnTime = Time.time;
        m_nextSpawn     = Time.time + element.TimeBeforeNext;
    }
Пример #5
0
    public bool ChangeToMatch(WaveElement origin, Tile.Direction to)
    {
        if (collapsed)
        {
            return(false);
        }

        bool changed = false;

        for (int i = 0; i < this.coeff.Length; i++)
        {
            bool edgeMatchFound = false;
            for (int j = 0; j < origin.coeff.Length; j++)
            {
                if (this.coeff[i] && origin.coeff[j])
                {
                    //if (possibleTiles[j].side[(int)to] == possibleTiles[i].side[(int)from])
                    Tile checkedTile = this.possibleTiles[i].tile;
                    Tile originTile  = origin.possibleTiles[j].tile;
                    if (checkedTile.Match(originTile, to))
                    {
                        edgeMatchFound = true;
                        break;
                    }
                }
            }

            if (!edgeMatchFound && coeff[i]) //if the edge doesn't match and the tile isn't already disabled
            {
                Remove(i);
                changed = true;
            }
        }

        if (changed)
        {
            CalculateProbAndEntropy();
        }

        return(changed);
    }
Пример #6
0
    IEnumerator spawnElement(WaveElement nextElement)
    {
        int int_framesToNextCall = nextElement.postSpawnDelay;

        Instantiate(nextElement.WaveObject, nextElement.spawnPosition, Quaternion.Euler(nextElement.spawnRotationEulerAngles));

        while (int_framesToNextCall > 0)
        {
            int_framesToNextCall--;
            yield return(new WaitForFixedUpdate());
        }

        currentSpawnID++;
        if (currentSpawnID >= WaveLength)
        {
            Destroy(gameObject);
        }

        bl_callingEnabled = true;

        yield break;
    }
Пример #7
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        GUIStyle head = new GUIStyle();

        head.normal.background = makeTextureColour(new Color(0.690f, 0.690f, 0.690f, 1));


        GUIStyle body = new GUIStyle();

        body.normal.background  = makeTextureColour(new Color(0.878f, 0.878f, 0.878f, 1));
        head.onHover.background = makeTextureColour(new Color(1f, 0f, 0f, 1));


        EditorGUIUtility.labelWidth = 100;
        EditorGUIUtility.fieldWidth = 20;


        if (GUILayout.Button("Collapse  All"))
        {
            foreach (WaveElement i in myTarget.elements)
            {
                i.vis = false;
            }
        }
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);

        for (int i = 0; i < myTarget.elements.Count; i++)
        {
            EditorGUILayout.BeginHorizontal(head);

            GUILayout.Width(5);
            myTarget.elements[i].vis = EditorGUILayout.Foldout(myTarget.elements[i].vis, GUIContent.none);

            addField(i, "behaviour");
            if (GUILayout.Button("^", GUILayout.Width(25)))
            {
                if (i > 0)
                {
                    WaveElement temp = myTarget.elements[i];
                    myTarget.elements[i]     = myTarget.elements[i - 1];
                    myTarget.elements[i - 1] = temp;
                }
            }
            if (GUILayout.Button("v", GUILayout.Width(25)))
            {
                if (i < myTarget.elements.Count - 1)
                {
                    WaveElement temp = myTarget.elements[i];
                    myTarget.elements[i]     = myTarget.elements[i + 1];
                    myTarget.elements[i + 1] = temp;
                }
            }
            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("X", GUILayout.Width(25)))
            {
                myTarget.elements.RemoveAt(i);
            }
            GUI.backgroundColor = Color.white;
            GUILayout.Label(("" + i), GUILayout.Width(25f));

            EditorGUILayout.EndHorizontal();


            EditorGUILayout.BeginVertical(body);
            if (myTarget.elements[i].vis)
            {
                switch (myTarget.elements[i].behaviour)
                {
                case ElementBehaviour.BULK:
                    spawnItem(i);
                    addField(i, "bulkElements");
                    time(i, "time");
                    break;

                case ElementBehaviour.SINGLE:
                    spawnItem(i);
                    break;

                case ElementBehaviour.WAIT:
                    time(i, "time");
                    break;
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        EditorGUILayout.BeginVertical();

        if (GUILayout.Button("Add New"))
        {
            myTarget.elements.Add(new WaveElement());
        }
        serializedObject.ApplyModifiedProperties();
    }