Esempio n. 1
0
    public void Build()
    {
        Room room = GetComponent <Room>();

        Grade           minGrade = UIHandler.Instance.floorBuilder.GetMinimumGrade(HeroSpawner.currentWave);
        List <TrapForm> preForms = DataHandler.Instance.GetDefaultTrapForms(capacity);
        List <TrapForm> forms    = new List <TrapForm>();

        if (minGrade != Grade.E)
        {
            foreach (TrapForm mf in preForms)
            {
                if ((int)minGrade <= (int)mf.grade)
                {
                    forms.Add(mf);
                }
            }

            if (forms.Count == 0)
            {
                forms = DataHandler.Instance.GetTrapFormsAtGrade(minGrade, capacity);
            }
            else if (forms.Count < capacity)
            {
                while (forms.Count < capacity)
                {
                    forms.Add(forms[Random.Range(0, forms.Count)]);
                }
            }
            else if (forms.Count > capacity)
            {
                List <TrapForm> newForms = new List <TrapForm>();
                for (int i = 0; i < capacity; i++)
                {
                    int idx = Random.Range(0, forms.Count);
                    newForms.Add(forms[idx]);
                }
                forms = newForms;
            }
        }
        else
        {
            forms = preForms;
        }

        foreach (TrapForm form in forms)
        {
            Trap trap = Instantiate(DataHandler.Instance.trapPrefab);
            trap.transform.SetParent(transform);
            int space = (traps.Count + 1) / 2;
            if (traps.Count % 2 == 1)
            {
                space *= -1;
            }
            Vector3 pos = room.roomCollider.bounds.center + new Vector3(spawnAligin * space, 0, 0);
            trap.Create(form, pos);

            traps.Add(trap);
        }
    }
 static void Main(string[] args)
 {
     OutPut.Welcome();
     Controller.StartMenu();
     Map.Create();
     Player.Create();
     Bonus.CreateBonus();
     Points.Create();
     Trap.Create();
     Mine.Create();
     StartGame.Start();
 }
Esempio n. 3
0
    // Use this for initialization
    void Start()
    {
        for (int i = 0; i < m_CreateItemCount; ++i)
        {
            var t = Random.Range(0, 3);
            switch (t)
            {
            case 0:
                Food.Create(Vector3.forward * 5 + Vector3.right * 3);
                break;

            case 1:
                Trap.Create(Vector3.forward * 5 + Vector3.right * 3);
                break;

            case 2:
                Trash.Create(Vector3.forward * 5 + Vector3.right * 3);
                break;
            }
        }
    }
Esempio n. 4
0
    public static Stuff Create(Floor floor, Cell cell, char data)
    {
        var item = Item.Create(floor, cell, data);

        if (item != null)
        {
            return(item);
        }
        var enemy = Enemy.Create(floor, cell, data);

        if (enemy != null)
        {
            return(enemy);
        }
        var trap = Trap.Create(floor, cell, data);

        if (trap != null)
        {
            return(trap);
        }
        return(null);
    }