Exemple #1
0
    bool SpecialSkillUsed(MyPlayerEvent e)
    {
        List <Vector2> positions = new List <Vector2>();

        string[] list = e.attribute_2.Split('|');
        foreach (string s in list)
        {
            if (s.Equals(""))
            {
                continue;
            }
            string[] coords = s.Split('_');
            positions.Add(new Vector2(float.Parse(coords[0]), float.Parse(coords[1])));
        }

        EffectType effectType = EnumUtil.EnumFromString <EffectType>(e.attribute_1, EffectType.Null);

        if (effectType == EffectType.Null || positions.Count == 0)
        {
            Debug.LogError("Cannot do special attack with an invalid effecttype or positions " + e.attribute_1 + " " + e.attribute_2 + "\n");
            return(false);
        }
        Peripheral.Instance.my_skillmaster.SimulateSkill(positions, effectType);
        return(true);
    }
Exemple #2
0
    public HitMe makeMonster(string name, int path, Vector3 posv, float point_factor, float xp_factor)
    {
        EnemyType enemy_type = EnumUtil.EnumFromString <EnemyType>(name, EnemyType.Null);

        if (enemy_type == EnemyType.Null)
        {
            Debug.LogError("Cannot make monster of type Null from " + name + "\n");
            return(null);
        }

        GameObject toy = zoo.getObject("Monsters/" + name, true);

        toy.tag = "Enemy";
        toy.transform.GetChild(0).tag = "Enemy";
        //  Debug.Log("LAYER " + toy.layer + "\n");
        //toy.layer = 12;//Unit
        toy.name = name + monster_count;
        monster_count++;



        toy.transform.SetParent(monsters_transform);
        toy.transform.position   = posv;
        toy.transform.localScale = Vector3.one;// = Vector3.one;

        HitMe hitme = toy.GetComponent <HitMe>();

        hitme.initStats(Central.Instance.getEnemy(enemy_type));

        // Debug.Log(hitme.gameObject.name + " " + hitme.GetInstanceID() + " " + Duration.time + " SPAWNED!\n");

        hitme.stats.point_factor = point_factor;
        //	Debug.Log("xp_factor " + xp_factor + "\n");
        if (xp_factor >= 0)
        {
            hitme.stats.SetXp(xp_factor);
        }


        targets.addByID(hitme);

        hitme.my_ai.my_dogtag.my_name = name + " " + Moon.Instance.getEnemyID();
        hitme.my_ai.my_dogtag.wave    = Moon.Instance.current_wave;

        AI ai = hitme.my_ai;

        ai.path        = path;
        ai.player      = WaypointMultiPathfinder.Instance.paths[path].finish.transform;
        ai.seewhen     = diagonal;
        ai.keepwalking = diagonal;
        ai.notsure     = diagonal;
        ai.Init();
        enemy_list.addMonster(toy.transform.GetInstanceID(), ai.my_dogtag);
        if (onPlacedToy != null)
        {
            onPlacedToy(toy.name, RuneType.Null, ToyType.Null);
        }
        //toy.transform.localRotation = ai.GetForwardDirection();
        return(hitme);
    }
Exemple #3
0
    public enemyStats LoadEnemy(string line)
    {
        JSONParser p      = new JSONParser(line);
        JSONObject pname  = new JSONObject();
        JSONObject pcost  = new JSONObject();
        JSONObject prunes = new JSONObject();
        JSONObject mass   = new JSONObject();

        p.parse();
        p.root.TryGetValue("name", out pname);
        p.root.TryGetValue("cost", out pcost);
        p.root.TryGetValue("mass", out mass); //this is here for wave balancing
        p.root.TryGetValue("runes", out prunes);

        EnemyType type = EnumUtil.EnumFromString <EnemyType>(pname.value, EnemyType.Null);

        if (type == EnemyType.Null)
        {
            Debug.LogError("Trying to initialize an unknown EnemyType from " + pname.value);
            return(null);
        }
        enemyStats enemy = new enemyStats(type);

        Central.Instance.enemies.Add(enemy);
        return(enemy);
    }
Exemple #4
0
    public void Load()
    {
        rowList.Clear();
        string[][] grid = CsvParser2.Parse(file.text);
        for (int i = 1; i < grid.Length; i++)
        {
            int           j   = 0;
            MyPlayerEvent row = new MyPlayerEvent();
            try
            {
                j               = 0;
                row.eventtype   = EnumUtil.EnumFromString <PlayerEvent>(grid[i][j++], PlayerEvent.Null);
                row.attribute_1 = grid[i][j++];
                row.attribute_2 = grid[i][j++];
                row.metric_1    = (grid[i][j].Equals(""))? 0 : float.Parse(grid[i][j]);
                j++;
                row.metric_2 = (grid[i][j].Equals("")) ? 0 : float.Parse(grid[i][j]);
                j++;
                row.wave_time = (grid[i][j].Equals("")) ? 0 : float.Parse(grid[i][j]);
                j++;
                row.eventtime = DateTime.Parse(grid[i][j]);
            }
            catch (Exception e)
            {
                Debug.Log("Could not parse " + String.Join(" | ", grid[i]) + " j " + j + " " + e.Message + "\n");
            }
            rowList.Add(row);
        }

        rowList.Sort();

        isLoaded = true;
    }
Exemple #5
0
    public void RunMe(int id)
    {
        //Tracker.track = false;
        current_run = id;

        MyPlayerEvent e = runs[current_run].findEventType(PlayerEvent.LoadGame);

        string[] settings = e.attribute_1.Split('|');

        Difficulty difficulty = EnumUtil.EnumFromString <Difficulty>(settings[0], Difficulty.Normal);

        int level = (int)e.metric_1;

        Central.Instance.game_saver.DeleteSaveGame(2);



        Central.Instance.game_saver.SelectSaveGame(2, true);
        Central.Instance.level_list.test_mode = true;
        Central.Instance.setCurrentLevel(level);
        Central.Instance.level_list.SetDifficulty(difficulty);

        Central.Instance.changeState(GameState.Loading, "NewLevel");
        skills_and_inventory = e.attribute_2;
        getNextEvent();
        am_running = true;
        done       = false;
        StartCoroutine(KeepTheFlow());
        StartCoroutine(runEvents());
        StartCoroutine(MaintainFF());
        StartCoroutine(TrackXP());
    }
Exemple #6
0
    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%            LOAD STATS



    public void LoadStats(InitLevel level)
    {
        Peripheral.Instance.addDreams(level.init_stats.dreams, Vector3.zero, false);
        Peripheral.Instance.max_dreams = 2000;
        PathfinderType PathType = PathfinderType.GridBased;

        Peripheral.Instance.SetInitHealth(level.init_stats.health);
        Peripheral.Instance.pathf    = PathType;
        Peripheral.Instance.tileSize = 1; // not supported through file
        if (level.init_stats.map_size_x > 0)
        {
            EagleEyes.Instance.setMapSize(level.init_stats.map_size_x, level.init_stats.map_size_y);
        }
        else
        {
            Debug.LogError("WTF no map size\n");
        }

        /*
         * LevelMod[] level_mod;
         * if (level.init_stats.level_mod != null && level.init_stats.level_mod.Length > 0)
         * {
         *  level_mod = level.init_stats.level_mod;
         * }
         * else
         * {
         *  level_mod = new LevelMod[1];
         *  level_mod[0] = new LevelMod();
         * }
         *
         * Peripheral.Instance.level_mod = level_mod;
         */
        Peripheral.Instance.env_type = EnumUtil.EnumFromString <EnvType>(level.init_stats.env, EnvType.Default);
    }
Exemple #7
0
//{"name":"slow_ghost",          "toy_type": "temporary","cost":"2","scale":{"x":"1","z":"1"},"ammo":"5", "arrow":"slow","required_building":"sensible_city","islandtype":"temporary","rune_type":"Slow"}


    public RuneType getRuneType()
    {
        RuneType rt = EnumUtil.EnumFromString <RuneType>(rune_type, RuneType.Null);

        if (rt == RuneType.Null)
        {
            Debug.LogError("Attempting to get an invalid runetype from InitToy " + name + "\n");
        }
        return(rt);
    }
Exemple #8
0
    public void SetDifficulty(String diff_string)
    {
        Difficulty diff = EnumUtil.EnumFromString(diff_string, Difficulty.Normal);

        levels[Central.Instance.current_lvl].difficulty = diff;
        if (Central.Instance.getState() == GameState.LevelList)
        {
            SetDifficultyLabel();
        }
    }
Exemple #9
0
    bool SkillUpgrade(MyPlayerEvent e)
    {
        int        order       = (int)e.metric_2;
        Toy        upgrade_me  = null;
        EffectType effect_type = EnumUtil.EnumFromString <EffectType>(e.attribute_1, EffectType.Null);

        if (effect_type == EffectType.Null)
        {
            Debug.LogError("Cannot upgrade toy of order " + order + " to invalid effectType " + e.attribute_1 + "\n");
            return(false);
        }

        foreach (Toy toy in toys)
        {
            if (toy.rune.order == order)
            {
                upgrade_me = toy;
            }
        }



        if (upgrade_me == null)
        {
            Debug.LogError("Could not find toy of order " + order + " to upgrade\n");
            return(false);
        }


        if (!upgrade_me.island.isBlocked() || upgrade_me.island.my_toy.building.construction_in_progress)
        {
            Debug.LogError("Toy of order " + order + " does not exist or is still building\n");
            return(false);
        }

        // StateType canUpgrade = upgrade_me.island.my_toy.rune.CanUpgrade(effect_type, upgrade_me.runetype);
        //if (canUpgrade == StateType.Yes)

        //{
        float success = upgrade_me.island.my_toy.rune.Upgrade(effect_type, true, true);

        if (success == 0)
        {
            Debug.LogError("Failed to upgrade toy " + order + " " + effect_type + "\n");
            return(false);
        }
        //}
        //else
        //{
        //Debug.LogError("Cannot upgrade toy " + order + " " + effect_type + ": " + canUpgrade + "\n");
        //return false;
        //}

        return(true);
    }
Exemple #10
0
    bool enemyEnabled(List <EnemyType> list, string s)
    {
        EnemyType type = EnumUtil.EnumFromString(s, EnemyType.Null);

        foreach (EnemyType t in list)
        {
            if (type == t)
            {
                return(true);
            }
        }
        return(false);
    }
Exemple #11
0
    bool TimeScaleChange(MyPlayerEvent e)
    {
        TimeScale timescale = EnumUtil.EnumFromString <TimeScale>(e.attribute_1, TimeScale.Null);

        if (timescale == TimeScale.Null)
        {
            Debug.LogError("Invalid TimeScaleChange to " + e.attribute_1 + "\n");
            return(false);
        }

        ff = timescale;
        return(true);
    }
Exemple #12
0
    //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%            LOAD WAVES

    public void LoadWaves(InitLevel level)
    {
        //random wave mode is not supported!!!
        List <int> pathlist = new List <int>();

        LevelMod level_mod = Peripheral.Instance.getLevelMod();

        Moon.Instance.Waves = new List <wave>();


        for (int x = 0; x < level.waves.Length; x++)
        {
            InitWave init_wave = level.waves[x];
            int      i         = 1;
            wave     mywave    = new wave();
            mywave.points = init_wave.points;
            mywave.xp     = 5f;

            for (int y = 0; y < init_wave.wavelets.Length; y++)
            {
                InitWavelet init_wavelet = init_wave.wavelets[y];
                init_wavelet.Modify(level_mod.wave_time_multiplier);
                mywave.add_wavelet(init_wavelet, false);
                i++;
            }
            mywave.wait = init_wave.wait_time;

            TimeName time_start = EnumUtil.EnumFromString <TimeName>(init_wave.time_start, TimeName.Null);
            TimeName time_end   = EnumUtil.EnumFromString <TimeName>(init_wave.time_end, TimeName.Null);
            if (time_start != TimeName.Null && time_end != TimeName.Null)
            {
                mywave.SetTime(time_start, time_end, init_wave.time_change_percent);
            }
            else if (time_start != TimeName.Null)
            {
                mywave.SetStartTime(time_start);
            }
            else
            {
                mywave.SetStartTime(TimeName.Day);
                // Debug.Log("WAVE missing start time! Assuming Day\n");
            }
            //mywave.adjust_total_run_time();
            Moon.Instance.AddWave(mywave);
        }
        if (LevelBalancer.Instance.am_enabled)
        {
            LevelBalancer.Instance.original_waves = CloneUtil.copyList <wave>(Moon.Instance.Waves);
            LevelBalancer.Instance.AutoSetPaths();
        }
    }
Exemple #13
0
    bool UsedInventory(MyPlayerEvent e)
    {
        Wish w = new Wish();

        w.type = EnumUtil.EnumFromString(e.attribute_1, WishType.Null);
        if (w.type == WishType.Null)
        {
            Debug.LogError("Invalid wishtype " + e.attribute_1 + "\n");
            return(false);
        }
        w.strength = 1;

        Peripheral.Instance.my_inventory.UseWish(w, true);

        return(true);
    }
Exemple #14
0
    public void LoadWish(InitLevel level)
    {
        WishDial[] dials = new WishDial[level.wishes.Length];

        for (int i = 0; i < level.wishes.Length; i++)
        {
            WishType type = EnumUtil.EnumFromString <WishType>(level.wishes[i].wishtype, WishType.Null);
            if (type == WishType.Null)
            {
                Debug.Log("Trying to load Null wishtype from file\n");
                continue;
            }

            dials[i] = new WishDial(type, level.wishes[i].count);
        }


        Moon.Instance.SetWishDials(dials);
    }
Exemple #15
0
    public bool ResetSkills(MyPlayerEvent e)
    {
        RuneType runetype = EnumUtil.EnumFromString <RuneType>(e.attribute_1, RuneType.Null);

        if (runetype == RuneType.Null)
        {
            Debug.LogError("Cannot reset skill for invalid runetype " + e.attribute_1 + "\n");
            return(false);
        }
        Rune rune = Central.Instance.getHeroRune(runetype);

        if (rune == null)
        {
            Debug.LogError("Cannot locate hero rune to reset: " + e.attribute_1 + "\n");
            return(false);
        }

        bool special = e.wave_time == -1;

        rune.resetSkills(special);

        return(true);
    }
Exemple #16
0
    public WaveletStatDetails calculateStats(InitWavelet wavelet, bool include_end_time)
    {
        WaveletStatDetails details = new WaveletStatDetails();

        details.details = new List <WaveStat>();
        WaveStat summary = new WaveStat();
        int      max     = (repeatTimes > 0)? wavelet.enemies.Length / repeatTimes : wavelet.enemies.Length;

        for (int x = 0; x < max; x++)
        {
            InitEnemyCount i       = wavelet.enemies[x];
            WaveStat       subStat = new WaveStat();

            float mass  = EnemyStore.getEffectiveMass(EnumUtil.EnumFromString(i.name, EnemyType.Null));
            float speed = EnemyStore.getSpeed(EnumUtil.EnumFromString(i.name, EnemyType.Null));

            //      Debug.Log($"BEFORE {i.name} Mass {mass} Speed {speed}\n");

            //if (speed == 0) Debug.LogError($"Trying to get speed for an unsupported enemy {i.name}\n");
            float time = i.c * wavelet.interval;

            if (i.name.Equals("Tank"))
            {
                mass += EnemyStore.getEffectiveMass(EnemyType.TinyTank);

                float speed_adjusted =
                    EnemyStore.getSpeed(EnemyType.Tank) * EnemyStore.getEffectiveMass(EnemyType.Tank)
                    + EnemyStore.getSpeed(EnemyType.TinyTank) * EnemyStore.getEffectiveMass(EnemyType.TinyTank);
                speed_adjusted /= mass;
                speed           = speed_adjusted;
            }

            if (i.name.Equals("SturdyTank"))
            {
                mass += EnemyStore.getEffectiveMass(EnemyType.Tank) + EnemyStore.getEffectiveMass(EnemyType.TinyTank);

                float speed_adjusted =
                    EnemyStore.getSpeed(EnemyType.SturdyTank) * EnemyStore.getEffectiveMass(EnemyType.SturdyTank)
                    + EnemyStore.getSpeed(EnemyType.Tank) * EnemyStore.getEffectiveMass(EnemyType.Tank)
                    + EnemyStore.getSpeed(EnemyType.TinyTank) * EnemyStore.getEffectiveMass(EnemyType.TinyTank);
                speed_adjusted /= mass;
                speed           = speed_adjusted;
            }

            if (i.name.Equals("ImpossibleTank"))
            {
                mass += EnemyStore.getEffectiveMass(EnemyType.SturdyTank) + EnemyStore.getEffectiveMass(EnemyType.Tank) + EnemyStore.getEffectiveMass(EnemyType.TinyTank);

                float speed_adjusted =
                    EnemyStore.getSpeed(EnemyType.SturdyTank) * EnemyStore.getEffectiveMass(EnemyType.SturdyTank)
                    + EnemyStore.getSpeed(EnemyType.Tank) * EnemyStore.getEffectiveMass(EnemyType.Tank)
                    + EnemyStore.getSpeed(EnemyType.TinyTank) * EnemyStore.getEffectiveMass(EnemyType.TinyTank)
                    + EnemyStore.getSpeed(EnemyType.ImpossibleTank) * EnemyStore.getEffectiveMass(EnemyType.ImpossibleTank);
                speed_adjusted /= mass;
                speed           = speed_adjusted;
            }

            if (i.name.Equals("Turtle"))
            {
                mass += 8 * EnemyStore.getEffectiveMass(EnemyType.TinyPlane);
            }

            //      Debug.Log($"AFTER {i.name} Mass {mass} Speed {speed}\n");


            summary.count += i.c * repeatTimes;
            summary.total_modified_mass += i.c * mass * repeatTimes;
            //   Debug.Log($"{i.c - 1} * {wavelet.interval} * {repeatTimes}\n");
            summary.time  += ((i.c - 1) * wavelet.interval) * repeatTimes;
            summary.speed += speed * i.c * repeatTimes;

            subStat.speed = speed;
            subStat.time  = time;
            subStat.count = i.c;
            subStat.total_modified_mass = mass * i.c;
            subStat.name = i.name;

            subStat.mass_per_second = speed * i.c * mass / time;

            details.details.Add(subStat);
        }
        float extra = (include_end_time) ? wavelet.end_wait : 0;

        summary.speed /= summary.count;
        summary.time  += (wavelet.enemies.Length - 1) * wavelet.lull + extra;
//        Debug.Log($" + {wavelet.enemies.Length - 1} * {wavelet.lull} + {extra}\n");
        //    Debug.Log($"Speed: {summary.speed} Mass: {summary.total_modified_mass} Time: {summary.time}\n");
        summary.mass_per_second = summary.speed * summary.total_modified_mass / summary.time;

        details.summary = summary;
        return(details);
    }
Exemple #17
0
 public void toggleEnemyType(int number, string text, bool currentValue)
 {
     currentEnemyType = EnumUtil.EnumFromString <EnemyType>(text, EnemyType.Null);
     summary.text     = toString();
 }
Exemple #18
0
    public unitStats LoadActor(string line)
    {
        //  Debug.Log("Loading actor\n");
        JSONObject pname    = new JSONObject();
        JSONObject pcost    = new JSONObject();
        JSONObject ptoytype = new JSONObject();
        //JSONObject pcost_runetype = new JSONObject ();
        JSONObject prune_type     = new JSONObject();
        JSONObject pcost_wishtype = new JSONObject();
        JSONParser p = new JSONParser(line);

        JSONObject ppermanent = new JSONObject();
        JSONObject pammo      = new JSONObject();
        JSONObject inv        = new JSONObject();



        JSONObject pmax_lvl          = new JSONObject();
        JSONObject exclude_skills    = new JSONObject();
        JSONObject required_building = new JSONObject();

        p.parse();
        p.root.TryGetValue("name", out pname);

        p.root.TryGetValue("cost", out pcost);

        p.root.TryGetValue("toy_type", out ptoytype);
        p.root.TryGetValue("rune_type", out prune_type);
        p.root.TryGetValue("cost_wishtype", out pcost_wishtype);
        p.root.TryGetValue("max_lvl", out pmax_lvl);


        p.root.TryGetValue("ammo", out pammo);
        p.root.TryGetValue("inventory", out inv);



        p.root.TryGetValue("islandtype", out ppermanent);
        p.root.TryGetValue("exclude_skills", out exclude_skills);
        p.root.TryGetValue("required_building", out required_building);
        unitStats test = Central.Instance.getToy(pname.value);


        if (test != null)
        {
            if (pmax_lvl != null)
            {
                test.setMaxLvl(int.Parse(pmax_lvl.value));
            }

            //    Debug.Log("Loading actor again\n");
            //thing has already been defined in a previous level. do not load most stats again

            return(test);
        }
        else
        {
            int cost = int.Parse(pcost.value);



            unitStats stats = new unitStats(pname.value);

            if (pmax_lvl != null)
            {
                stats.setMaxLvl(int.Parse(pmax_lvl.value));
            }
            stats.isUnlocked = false;
            RuneType rune_type = (prune_type != null) ? EnumUtil.EnumFromString(prune_type.value, RuneType.Null) : RuneType.Null;
            ToyType  toy_type  = (ptoytype != null) ? EnumUtil.EnumFromString(ptoytype.value, ToyType.Null) : ToyType.Null;
            //WishType wish_type = WishType.Null;
            CostType cost_type = CostType.Dreams;

            stats.toy_id.toy_type  = toy_type;
            stats.toy_id.rune_type = rune_type;



            cost_type = TowerStore.costType(rune_type, toy_type);

            //if (pcost_wishtype != null) wish_type = Get.WishTypeFromString(pcost_wishtype.value);
            if (required_building != null)
            {
                stats.required_building = (required_building.value);
            }
            stats.setCost(cost_type, cost);


            stats.island_type = ppermanent != null?EnumUtil.EnumFromString(ppermanent.value, IslandType.Permanent) : IslandType.Permanent;


            if (pammo != null)
            {
                stats.ammo = int.Parse(pammo.value);
            }
            Central.Instance.setUnitStats(stats, false);
            return(stats);
        }
    }
Exemple #19
0
    void OnInput()
    {
        if (!enabled)
        {
            Noisemaker.Instance.Click(ClickType.Error);
            return;
        }

        ClickType click_outcome = ClickType.Null;

        if (type.Equals("toy_selected"))
        {
            click_outcome = ClickType.Success;
            SetSelectedToy(true);
        }

        if ((type.Equals("selected")) && selected)
        {
            click_outcome = ClickType.Cancel;
            SetSelectedToy(false);
        }
        if (type.Equals("meter_selected") && selected)
        {
            click_outcome = ClickType.Cancel;
            selected      = false;
            SetSelectedToy(false);
        }
        else if (type.Equals("meter_selected"))
        {
            peripheral.SelectToy(content, EnumUtil.EnumFromString(content_detail, RuneType.Null));
            click_outcome = ClickType.Success;
            selected      = true;
        }


        if (type.Equals("info"))
        {
            Debug.Log("Info button pressed? Is this still used?\n");
            click_outcome = ClickType.Success;
            Destroy(parent);
        }

        if (type.Equals("InGame"))
        {
            click_outcome = ClickType.Success;
            onSelected?.Invoke(SelectedType.Null, "");
            switch (content)
            {
            case "StartWave":
                Peripheral.Instance.StartWave();
                click_outcome = ClickType.Null;
                break;

            case "MainMenu":
                peripheral.ChangeTime(TimeScale.Pause);
                EagleEyes.Instance.PlaceMenu(true);
                break;

            case "Pause":
                selected = !selected;
                peripheral.TogglePause();
                break;

            case "FastForward":
                peripheral.ToggleFast();
                break;

            case "FastForward_SUPERFAST":
                peripheral.ChangeTime(TimeScale.SuperFastPress);
                break;

            default:
                break;
            }
        }

        if (type.Equals("MainMenu"))
        {
            click_outcome = ClickType.Success;
            switch (menu_button)
            {
            case MenuButton.Play:
                Central.Instance.game_saver.toggleSaveGamePanel();
                break;

            case MenuButton.Start:
                click_outcome = content.Equals("CancelConfirm") ? ClickType.Cancel : ClickType.Success;
                Central.Instance.changeState(GameState.LevelList, content);
                break;

            case MenuButton.Continue:
                Debug.Log("Continue play from main menu\n");
                EagleEyes.Instance.PlaceMenu(false);
                break;

            case MenuButton.Quit:
                Central.Instance.changeState(GameState.Quit);
                break;

            case MenuButton.LoadSnapshot:
                Central.Instance.changeState(GameState.Loading, content);     //why the hell is this all done via strings
                break;

            case MenuButton.GoBack1:
                Central.Instance.changeState(GameState.Loading, menu_button.ToString());
                break;

            case MenuButton.GoBack2:
                Central.Instance.changeState(GameState.Loading, menu_button.ToString());
                break;

            case MenuButton.LoadLatestGame:
                Central.Instance.changeState(GameState.Loading, content);
                break;

            case MenuButton.LoadStartLevelSnapshot:
                Central.Instance.changeState(GameState.Loading, content);
                break;

            case MenuButton.ToMap:
                if (content.Equals("CancelConfirmToMap"))
                {
                    click_outcome = ClickType.Cancel;
                    Central.Instance.changeState(GameState.InGame, content);
                }
                else
                {
                    click_outcome = ClickType.Success;
                    Central.Instance.changeState(GameState.LevelList, content);
                }
                break;

            case MenuButton.Settings:
                EagleEyes.Instance.my_settings_panel.TogglePanel();
                break;

            case MenuButton.Rewards:
                EagleEyes.Instance.rewards_scroll_driver.Toggle();
                break;

            default:
                break;
            }
        }

        if (type.Equals("Lost"))
        {
            switch (menu_button)

            {
            case MenuButton.LoadStartLevelSnapshot:
                Debug.Log("Button change state to loading\n");
                Central.Instance.changeState(GameState.Loading, content);
                click_outcome = ClickType.Success;
                break;

            case MenuButton.Quit:
                Debug.Log("I wanna quit\n");
                Application.Quit();
                break;

            default:
                break;
            }
        }
        if (type.Equals("Settings"))
        {
            //bool ok = false;
            switch (content)
            {
            case "VolumePlus":
                click_outcome = (EagleEyes.Instance.my_settings_panel.IncreaseVolume()) ? ClickType.Success : ClickType.Error;
                break;

            case "VolumeMinus":
                click_outcome = (EagleEyes.Instance.my_settings_panel.DecreaseVolume()) ? ClickType.Success : ClickType.Error;
                break;

            case "Play":
                Noisemaker.Instance.setMute(false);
                EagleEyes.Instance.mySoundButtons.updateButtons();
                click_outcome = ClickType.Success;
                break;

            case "Mute":
                Noisemaker.Instance.setMute(true);
                EagleEyes.Instance.mySoundButtons.updateButtons();
                click_outcome = ClickType.Success;
                break;
            }
        }
        if (type.Equals("Marketplace"))
        {
            EagleEyes.Instance.marketplace_driver.Init(true);
        }
        if (type.Equals("LevelList"))
        {
            switch (menu_button)
            {
            case MenuButton.Start:
                //	Debug.Log("Button change state to loading");

                Central.Instance.changeState(GameState.Loading, content);
                break;

            case MenuButton.Inventory:
                switch (content)
                {
                case "cancel":

                    Central.Instance.level_list.special_skill_button_driver.DisableMe();
                    Central.Instance.game_saver.SaveGame(SaveWhen.BetweenLevels);
                    click_outcome = ClickType.Cancel;
                    break;

                case "upgrade":

                    click_outcome = ClickType.Action;
                    Central.Instance.level_list.special_skill_button_driver.upgradeSelected();
                    break;

                case "givemestuff":
                    click_outcome = ClickType.Action;
                    ScoreKeeper.Instance.SetTotalScore(820);
                    Central.Instance.game_saver.SaveGame(SaveWhen.BetweenLevels);
                    break;

                case "reset_special_skills":
                    break;

                default:
                    //  Debug.Log($"Special skill button set parent {content}\n");
                    Central.Instance.level_list.special_skill_button_driver.SetParent(null);
                    break;
                }
                break;

            case MenuButton.ToMainMenu:
                click_outcome = ClickType.Success;
                Central.Instance.changeState(GameState.MainMenu);
                break;

            default:
                break;
            }
        }

        if (type.Equals("Level"))
        {
            click_outcome = ClickType.Success;
            int lvl = int.Parse(content);
            if (lvl == -1)
            {
                click_outcome = ClickType.Cancel;
            }

            if (!Central.Instance.setCurrentLevel(lvl))
            {
                click_outcome = ClickType.Cancel;
                return;
            }
            Central.Instance.level_list.setLevelInfo(lvl);
            //Otherwise do onButtonClick below
        }

        if (type.Equals("Won"))
        {
            click_outcome = ClickType.Success;
            if (menu_button == MenuButton.ToMap)
            {
                Central.Instance.changeState(GameState.LevelList, content);
            }
        }
        if (onButtonClicked != null)
        {
            onButtonClicked(type, content);
        }
        Noisemaker.Instance.Click(click_outcome);
    }
Exemple #20
0
    /*
     *  public void StopTween(GameObject obj){
     *          Tweener[] stopme = obj.GetComponentsInChildren<Tweener> ();
     *          for (int i = 0; i < stopme.Length; i++)
     *                  {
     *                          stopme[i].StopMe();
     *                  }
     *  }
     */
    public void Do()
    {
        //    Debug.Log("Doing gameaction " + this._type + " " + this.name + " " + _text + "\n");
        switch (_type)
        {
        case ActionType.UIFilter:
            if (_name.Equals(""))
            {
                EagleEyes.Instance.ResetUIFilter();
            }
            else
            {
                EagleEyes.Instance.SetUIFilter(_name, _text);
            }
            break;

        case ActionType.SetSensibleWishUplift:
            Peripheral.Instance.getLevelMod().sensible_wish_uplift = _number;
            break;

        case ActionType.Panel:
            if (Peripheral.Instance == null)
            {
                Debug.Log("NO PERIPHERAL\n");
                return;
            }
            if (Peripheral.Instance.zoo == null)
            {
                Debug.Log("NO ZOO\n");
                return;
            }

            GameObject panel = Peripheral.Instance.zoo.getObject(_name, true);
            if (panel == null)
            {
                Debug.LogError("GameAction could not find object " + _name + "\n");
            }
            if (!_bool)
            {
                panel.transform.SetParent(EagleEyes.Instance.events.transform);
            }
            else
            {
                panel.transform.SetParent(EagleEyes.Instance.world_space_events.transform);
            }
            panel.gameObject.transform.GetChild(0).gameObject.SetActive(true);
            panel.transform.localPosition = Vector3.zero;
            panel.transform.localScale    = Vector3.one;
            panel.transform.localRotation = Quaternion.identity;
            break;

        case ActionType.ShowIslands:
            Debug.Log("Show islands " + _name + " " + _bool);
            IslandType type = EnumUtil.EnumFromString <IslandType>(_name, IslandType.Null);
            if (type == IslandType.Null)
            {
                Debug.LogError("Event trying to show (" + _bool + ")islands of invalid type: " + _name + "\n");
                return;
            }
            Monitor.Instance.ShowIslandSprites(_bool, type);
            break;

        case ActionType.EnemyDescription:

            GameObject enemy_desc = Peripheral.Instance.zoo.getObject("Tutorial/Descriptions/generic_enemy_description", true);
            if (enemy_desc == null)
            {
                Debug.LogError("GameAction could not find object " + _name + "\n");
            }
            enemy_desc.transform.SetParent(EagleEyes.Instance.events.transform);


            enemy_desc.gameObject.transform.GetChild(0).gameObject.SetActive(true);
            enemy_desc.transform.localPosition = Vector3.zero;
            enemy_desc.transform.localScale    = Vector3.one;
            enemy_desc.transform.localRotation = Quaternion.identity;
            enemy_desc.GetComponent <EnemyDescriptionLabel>().setType(_text);
            RectTransform b   = enemy_desc.GetComponent <EnemyDescriptionButton>().button;
            Vector3       pos = b.localPosition;
            pos.y += _number * -6.5f;
            //Debug.Log(_number + "\n");
            b.localPosition = pos;
            break;

        case ActionType.MakeFloaty:
            //GameObject floaty = Peripheral.Instance.zoo.getObject(_name, true);
            //if (floaty == null) { Debug.Log("GameAction could not find object " + _name + "\n"); }
            //  floaty.GetComponent<Floaty>().Init(_vector);
            break;

        case ActionType.AddWish:

            WishType w = Get.WishTypeFromString(_text);
            // Debug.Log("We should add a wish " + _text + " " + w + "\n");
            Peripheral.Instance.my_inventory.AddWish(w, _number, 1);
            break;

        case ActionType.AddDream:
            if (_number <= 0)
            {
                return;
            }
            Peripheral.Instance.addDreams(_number, Vector3.zero, false);
            break;

        case ActionType.GiveSpecialSkill:
            EffectType effect_type = EnumUtil.EnumFromString <EffectType>(_name, EffectType.Null);
            RuneType   rune_type   = EnumUtil.EnumFromString <RuneType>(_text, RuneType.Null);
            Rune       r           = Central.Instance.getHeroRune(rune_type);

            if (r == null)
            {
                Debug.LogError("Cannot find a rune for hero of type " + rune_type + ", cannot give skill " + effect_type + "\n");
            }
            r.GiveSpecialSkill(effect_type);
            break;

        case ActionType.MakeWish:
            List <Wish> inv = new List <Wish>();
            inv.Add(new Wish(WishType.Sensible, 0.2f * _number));
            inv.Add(new Wish(WishType.MoreDamage, 0.1f * _number));
            inv.Add(new Wish(WishType.MoreXP, 015f * _number));
            inv.Add(new Wish(WishType.MoreDreams, 0.1f * _number));
            inv.Add(new Wish(WishType.MoreHealth, 0.1f * _number));
            if (onMakeWish != null)
            {
                onMakeWish(inv, _vector);
            }

            Debug.Log("We should make a wish\n");
            break;

        case ActionType.Pause:
            Peripheral.Instance.Pause(true);
            break;

        case ActionType.Resume:
            //       Debug.Log("Resuming\n");
            Peripheral.Instance.Pause(false);
            break;

        case ActionType.DisableMonitor:
            Monitor.Instance.is_active = _bool;
            break;

        case ActionType.HideUIElement:
            //name is include, //text is exclude
            //	Debug.Log("Setting " + _name + " to " + _bool + "\n");
            EagleEyes.Instance.PlaceElement(_name, _bool);
            break;

        case ActionType.DisableUIElement:
            //name is include, //text is exclude
            //BUTTON HAS TO BE in GUI STATES WITH A MYLABEL

            EagleEyes.Instance.DisableElement(_name, _bool);
            //EagleEyes.Instance.SetEnableButtons(_name, _text, _bool);
            break;

        case ActionType.RemoveEventObjects:
            RemoveEventObjects();
            break;

        case ActionType.UnlockToy:
            Debug.Log("Unlocking toy " + _text + "\n");
            //Peripheral.Instance.ActivateToy(_text);
            unitStats toy = Central.Instance.getToy(_text);
            toy.isUnlocked = true;
            EagleEyes.Instance.UpdateToyButtons("blah", ToyType.Null, false);
            break;

        case ActionType.PointSpyGlass:
            if (Monitor.Instance != null)
            {
                Monitor.Instance.my_spyglass.PointSpyglass(_vector, true);
            }
            break;

        case ActionType.EnableSpyGlass:
            if (Monitor.Instance != null)
            {
                Monitor.Instance.my_spyglass.DisableByEvent(!_bool);
            }
            break;

        case ActionType.RemoveObject:
            if (_target != null)
            {
                foreach (GameObject t in _target)
                {
                    Peripheral.Instance.zoo.returnObject(t);
                }
            }
            if (_name != null)
            {
                Debug.Log("GameAction removing object with name, TERRIBLE\n");
            }
            Peripheral.Instance.zoo.returnObject(GameObject.Find(_name));
            break;

        case ActionType.EnableReward:
            RewardType rt = EnumUtil.EnumFromString <RewardType>(_text, RewardType.Null);
            if (rt != RewardType.Null)
            {
                RewardOverseer.RewardInstance.EnableReward(rt);
            }
            else
            {
                Debug.LogError(this.gameObject.name + " RewardType gameAction has an invalid rewardType( " + _text + ")\n");
            }
            break;

        default:
            Debug.LogError(this.gameObject.name + " " + _type + " gameAction has an unsupported ActionType\n");
            break;
        }
    }