Ejemplo n.º 1
0
    private void Update()
    {
        waveTimer  += Time.deltaTime * waveSpeed;
        spawnTimer += Time.deltaTime;

        if (spawnQueue.Count > 0 && spawnQueue[0].maxTime < waveTimer)
        {
            callQueue.Add(spawnQueue[0]);
            MonsterStone temp = spawnQueue[0];
            spawnQueue.RemoveAt(0);
            waveTimer = 0;
            waveCount++;
            newWave.Invoke(temp);
            if (targetWave == 0)
            {
                waveSpeed = 1;
            }



            targetWave--;
        }

        if (spawnTimer > lastSpawn + spawnDelay)
        {
            lastSpawn = spawnTimer;
            if (callQueue.Count > 0)
            {
                SpawnMonster();
            }
        }
    }
Ejemplo n.º 2
0
    private static List <MonsterStone.MonsterAbility> getAbilities(XmlNodeList list)
    {
        List <MonsterStone.MonsterAbility> resualt = new List <MonsterStone.MonsterAbility>();

        for (int i = 0; i < list.Count; i++)
        {
            resualt.Add(MonsterStone.getAbility(list[i].InnerText));
        }
        return(resualt);
    }
Ejemplo n.º 3
0
    IEnumerator DropUI(MonsterStone monsterStone)
    {
        float         timer = 0;
        RectTransform UIPointer;

        if (passiveDropElements.Count > 0)
        {
            UIPointer = passiveDropElements.Dequeue();
            UIPointer.gameObject.active = true;
        }
        else
        {
            UIPointer            = Instantiate(baseStone).GetComponent <RectTransform>();
            UIPointer.parent     = centerPoint;
            UIPointer.localScale = Vector3.one;
        }

        UIPointer.anchoredPosition = new Vector3(centerPoint.anchoredPosition.x, centerPoint.anchoredPosition.y - offset, 0);
        Transform abilityParentPointer = UIPointer.transform.Find("Abilities");

        for (int i = 0; i < abilityParentPointer.childCount; i++)
        {
            if (i < monsterStone.abilitys.Count)
            {
                abilityParentPointer.GetChild(i).gameObject.active = true;
                Image monsterAbility = abilityParentPointer.GetChild(i).GetComponent <Image>();
                monsterAbility.material = monsterStone.getAblityImage(i);
            }
            else
            {
                abilityParentPointer.GetChild(i).gameObject.active = false;
            }
        }

        Vector2 startPosition = new Vector3(UIPointer.anchoredPosition.x, UIPointer.anchoredPosition.y);

        while (true)
        {
            timer += Time.fixedDeltaTime / getDropTime;

            Vector3 newPosition = new Vector3(startPosition.x, startPosition.y - (canvas.rect.height + startPosition.y) * timer, 0);
            UIPointer.anchoredPosition = newPosition;
            if (timer >= 1)
            {
                UIPointer.gameObject.active = false;
                passiveDropElements.Enqueue(UIPointer);
                break;
            }

            yield return(new WaitForFixedUpdate());
        }
    }
Ejemplo n.º 4
0
 public void newWaveCall(MonsterStone monsterStone)
 {
     for (int i = 0; i < maxVisableStones; i++)
     {
         if (i < Spawn.instance.spawnQueue.Count)
         {
             updateMonsterStoneInfo(i);
         }
         else
         {
             monsterStoneUI[i].active = false;
         }
     }
     StartCoroutine(MoveUI());
     StartCoroutine(DropUI(monsterStone));
 }
Ejemplo n.º 5
0
    public static List <MonsterStone> convertXmlToMonsterStone(string xmlPath)
    {
        XmlDocument document = new XmlDocument();

        document.Load(xmlPath);

        XmlNodeList nodes = document.SelectNodes("/waveList")[0].ChildNodes;

        List <MonsterStone> resualt = new List <MonsterStone>();

        for (int i = 0; i < nodes.Count; i++)
        {
            int timer = 0;
            MonsterStone.MonsterType           type      = MonsterStone.MonsterType.Harpy;
            List <MonsterStone.MonsterAbility> abilities = null;
            for (int j = 0; j < nodes[i].ChildNodes.Count; j++)
            {
                switch (nodes[i].ChildNodes[j].Name.ToLower())
                {
                case "timer":
                    int.TryParse(nodes[i].ChildNodes[j].InnerText, out timer);
                    break;

                case "type":
                    type = MonsterStone.ParseStringToType(nodes[i].ChildNodes[j].InnerText);
                    break;

                case "abilities":
                    abilities = getAbilities(nodes[i].ChildNodes[j].ChildNodes);
                    break;
                }
            }

            resualt.Add(new MonsterStone(type, timer, abilities));
        }

        return(resualt);
    }