Ejemplo n.º 1
0
    public bool SellTower(MyPlayerEvent e)
    {
        if (e.event_complete)
        {
            return(true);
        }

        foreach (Toy t in toys)
        {
            if (t.rune.order == e.metric_1)
            {
                Peripheral.Instance.sellToy(t, 0);
                return(true);
            }
        }
        Debug.LogError("Could not find toy for event " + e.toString() + "\n");
        return(false);
    }
Ejemplo n.º 2
0
    IEnumerator runEvents()
    {
        yield return(new WaitForSeconds(0.5f));


        while (am_running && !done)
        {
            MyPlayerEvent e = runs[current_run].GetRowList()[current_event];

            if (e.event_complete)
            {
                getNextEvent();
                e = runs[current_run].GetRowList()[current_event];
            }



            if (!e.event_complete && timeToExecuteEvent(e))
            {
                executeEvent ee = null;

                if (e.eventtype == PlayerEvent.TowerBuilt)
                {
                    ee += new executeEvent(TowerBuild);                                        //force
                }
                if (e.eventtype == PlayerEvent.UsedInventory)
                {
                    ee += new executeEvent(UsedInventory);                                           //force
                }
                if (e.eventtype == PlayerEvent.SkillUpgrade)
                {
                    ee += new executeEvent(SkillUpgrade);
                }
                if (e.eventtype == PlayerEvent.AmmoRecharge)
                {
                    ee += new executeEvent(AmmoRecharge);                                          //force
                }
                if (e.eventtype == PlayerEvent.SpecialSkillUsed)
                {
                    ee += new executeEvent(SpecialSkillUsed);                                              //force
                }
                if (e.eventtype == PlayerEvent.StartWaveEarly)
                {
                    ee += new executeEvent(StartWaveEarly);
                }
                if (e.eventtype == PlayerEvent.TimeScaleChange)
                {
                    ee += new executeEvent(TimeScaleChange);
                }
                if (e.eventtype == PlayerEvent.SellTower)
                {
                    ee += new executeEvent(SellTower);
                }

                if (ee != null)
                {
                    Debug.Log("Executing event " + e.toString() + "\n");
                    bool success = ee(e);
                    if (!success)
                    {
                        Debug.LogError("Event " + e.toString() + " FAILED to execute\n");
                    }
                }

                e.event_complete = true;
            }
            yield return(StartCoroutine(CoroutineUtil.WaitForRealSeconds(0.3f)));
        }
    }