Example #1
0
//#endif


    public void loadSnapshot(FakePlayerSaver saver)
    {
//#if UNITY_EDITOR
        if (saver.towers.Count == 0)
        {
            return;
        }
        Init();
        current_snapshot  = saver.current_snapshot;
        snapshot_filename = saver.snapshot_filename;
        ff = saver.ff;
        force_all_towers   = saver.force_all_towers;
        force_all_upgrades = saver.force_all_upgrades;

        upgrades = CloneUtil.copyList <TowerUpgrade>(saver.upgrades);
        for (int i = 0; i < towers.Count; i++)
        {
            towers[i].loadSnapshot(saver.towers[i]);
        }

        foreach (Firearm f in Peripheral.Instance.firearms)
        {
            if (f.toy.toy_type == ToyType.Temporary)
            {
                ghosts.Add(f.toy);
            }
        }

//#endif
    }
Example #2
0
    public static List <Defense> getDefenses(EnemyType type, bool clone)
    {
        if (enemyDefenses == null)
        {
            initDefenses();
        }

        List <Defense> defenses = enemyDefenses[type];

        return((clone) ? CloneUtil.copyList <Defense>(defenses) : defenses);
    }
Example #3
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();
        }
    }
Example #4
0
 public void ToggleMe()
 {
     am_enabled = !am_enabled;
     panel.SetActive(am_enabled);
     if (am_enabled)
     {
         Init();
         LevelBalancer.Instance.original_waves = CloneUtil.copyList <wave>(Moon.Instance.Waves);
         LevelBalancer.Instance.AutoSetPaths();
         EagleEyes.Instance.WaveButton(false);
         Moon.Instance.abortWave();
     }
     else
     {
         EagleEyes.Instance.WaveButton(true);
     }
 }
Example #5
0
    public enemyStats DeepClone()
    {
        enemyStats my_clone = new enemyStats();

        my_clone.name         = string.Copy(this.name);
        my_clone.target       = this.target;
        my_clone.ammo         = this.ammo;
        my_clone.remaining_xp = this.remaining_xp;
        my_clone.init_xp      = this.init_xp;
        my_clone.inventory    = CloneUtil.copyList(this.inventory);
        my_clone.mass         = this.mass;
        my_clone.speed        = this.speed;
        my_clone.defenses     = CloneUtil.copyList(defenses);
        //my_clone.defense = this.defense;
        //my_clone.vf_defense = this.vf_defense;
        return(my_clone);
    }
Example #6
0
    public wave DeepClone()
    {
        wave my_clone = new wave();

        my_clone.wavelets       = CloneUtil.copyList <InitWavelet>(wavelets);
        my_clone.wait           = this.wait;
        my_clone.retry          = this.retry;
        my_clone.total_run_time = this.total_run_time;
        my_clone.points         = this.points;
        my_clone.xp             = this.xp;

        my_clone.monster_count       = this.monster_count;
        my_clone.time_name_start     = this.time_name_start;
        my_clone.time_name_end       = this.time_name_end;
        my_clone.time_change_percent = this.time_change_percent;
        my_clone.time_start          = this.time_start;
        my_clone.time_change_at      = this.time_change_at;
        my_clone.enemies_left        = this.enemies_left;

        return(my_clone);
    }
Example #7
0
    public FakePlayerSaver getSnapshot()
    {
        FakePlayerSaver saver = new FakePlayerSaver();

//#if UNITY_EDITOR
        saver.current_snapshot  = current_snapshot;
        saver.snapshot_filename = snapshot_filename;
        saver.ff                 = ff;
        saver.upgrades           = CloneUtil.copyList <TowerUpgrade>(upgrades);
        saver.force_all_upgrades = force_all_upgrades;
        saver.force_all_towers   = force_all_towers;

        List <BuildTowerSaver> towers_saver = new List <BuildTowerSaver>();

        for (int i = 0; i < towers.Count; i++)
        {
            towers_saver.Add(towers[i].getSnapshot());
        }
        saver.towers = towers_saver;

//#endif
        return(saver);
    }
Example #8
0
    public void ChangeMe(bool revert)
    {
        am_transformed = !revert;
        is_active      = am_transformed;
        TransformedProperties tf = (revert) ? before : getProperties(after);

        setCollider(tf);


        my_hitme.sprite_renderer.sprite              = tf.sprite;
        my_hitme.my_ai.speed                         = tf.speed;
        my_hitme.my_ai.current_speed                 = tf.speed;
        my_hitme.my_ai.rotation_interval             = tf.rotation_interval;
        my_hitme.my_ai.rotation_inverse_speed_factor = tf.rotation_inverse_speed_factor;
        my_hitme.my_ai.rotation_lerp_amount          = tf.rotation_lerp_amount;
        my_hitme.getCollider().sharedMaterial = Get.getPhysicsMaterial(tf.physics_material);


        if (revert)
        {
            my_hitme.init_defenses = CloneUtil.copyList <Defense>(tf.defenses);
            my_hitme.defenses      = CloneUtil.copyList <Defense>(tf.defenses);
        }
        else
        {
            AvgDefenses(my_hitme.init_defenses, tf.defenses, 0.5f);
            AvgDefenses(my_hitme.defenses, tf.defenses, 0.5f);
        }

        my_hitme.sprite_renderer.gameObject.transform.localScale = tf.sprite_size;
        my_hitme.my_rigidbody.drag        = tf.linear_drag;
        my_hitme.my_rigidbody.angularDrag = tf.angular_drag;
        my_hitme.my_ai.AmHit();
        my_hitme.my_ai.ForceVelocity();

        //  Debug.Log("Finished converting " + this.name + " am transformed " + am_transformed + "\n");
    }
Example #9
0
 public void setPossibleWishes(List <WishDial> possible_wishes)
 {
     this.possible_wishes = CloneUtil.copyList <WishDial>(possible_wishes);
 }
Example #10
0
 public List <WishDial> getPossibleWishes()
 {
     return(CloneUtil.copyList <WishDial>(possible_wishes));
 }
Example #11
0
    public void initStats(enemyStats s)
    {
        //	if (tween == null) {tween = this.gameObject.AddComponent<Tweener>();}
        if (my_ai == null)
        {
            my_ai = GetComponent <AI>();
        }
        if (my_body == null)
        {
            my_body = GetComponent <Body>();
        }
        if (my_rigidbody == null)
        {
            my_rigidbody = GetComponentInChildren <Rigidbody2D>();
        }
        if (my_collider == null)
        {
            my_collider = GetComponentInChildren <Collider2D>();
        }

        if (my_visuals == null || !my_visuals.gameObject.activeSelf)
        {
            initVisuals();
        }



        modified_defenses             = false;
        normalize_defenses_is_running = false;

        if (mass != null)
        {
            mass.gameObject.transform.SetParent(transform);
        }
        if (mass == null)
        {
            mass = Peripheral.Instance.zoo.getObject("Monsters/Helpers/Mass", true).GetComponent <Mass>();
        }
        if (!mass.gameObject.activeSelf)
        {
            mass.gameObject.SetActive(true);
        }

        _initMass();
        mass.gameObject.transform.SetParent(transform);
        mass.gameObject.transform.localPosition = Vector3.zero;
        mass.gameObject.transform.localScale    = Vector3.one;
        mass.gameObject.transform.localRotation = Quaternion.identity;
        stats = s.DeepClone();

        init_defenses = CloneUtil.copyList <Defense>(stats.defenses);
        defenses      = CloneUtil.copyList <Defense>(stats.defenses);


        //tileSize = Peripheral.Instance.tileSize;

        init_scale = Vector3.one;
        this.transform.localScale = init_scale;

        if (init_mass == -1)
        {
            init_mass = my_rigidbody.mass;
        }
        else
        {
            my_rigidbody.mass = init_mass;
            mass.Define(my_rigidbody, this.transform.GetChild(0).transform, mass_factor, status_bar_location, scale_transform);
        }

        if (init_speed == -1)
        {
            init_speed = my_ai.speed;
        }
        else
        {
            my_ai.speed = init_speed;
        }


        wish_list = new WishType[stats.inventory.Count];

        for (int i = 0; i < stats.inventory.Count; i++)
        {
            wish_list[i] = stats.inventory[i].type;
        }

        mass.SetPosition(status_bar_location);
        dying = false;
        InvokeRepeating("CheckIfAlive", 0, check_if_alive_repeat_rate);

        for (int i = 0; i < enemy_tech.Length; i++)
        {
            enemy_tech[i].setActive(true);
        }

        lavas = new List <Lava>();
        //   CheckBasicStats(s); //for wave balancing purposes, reminder that these stats are now in the init file, not on the prefab
    }
Example #12
0
    public bool Init(HitMe _hitme, float[] stats, float factor)
    {
        if (_hitme == null)
        {
            Debug.Log("WTF hitme is null\n");
        }
        after = TransformType.Null;
        float roll    = UnityEngine.Random.Range(0, 1f);
        float current = 0;

        //    Debug.Log("roll is " + roll + " stats: " + stats[0] + " % " + " timer " + stats[1] + "\n");
        timer = stats[1] / factor;

        if (am_transformed)
        {
            return(true);
        }

/*
 *      float finisher_percent = (stats.Length == StaticStat.StatLength(EffectType.Transform, true)) ? stats[2]/100f : 0;
 *      if (finisher_percent > 0 && UnityEngine.Random.RandomRange(0, 1) < finisher_percent)
 *      {
 *          after = TransformType.Whale;
 *          timer = 99f;
 *      }
 *
 *      else
 *      {*/
        bool flying = (_hitme.gameObject.layer == Get.flyingProjectileLayer);

        if (roll < stats[0])
        {
            after = (flying)? TransformType.FruitFly :  TransformType.StickFigure;
        }
        //}


        if (!ValidateMe(after))
        {
            //     Debug.Log("Cancelling converter\n");
            return(false);
        }


        if (my_hitme == null)
        {
            my_hitme = _hitme;

            before.sprite      = my_hitme.sprite_renderer.sprite;
            before.sprite_size = my_hitme.sprite_renderer.gameObject.transform.localScale;
            getCollider(before);
            before.physics_material              = my_hitme.getCollider().sharedMaterial.name;
            before.rotation_interval             = my_hitme.my_ai.rotation_interval;
            before.rotation_inverse_speed_factor = my_hitme.my_ai.rotation_inverse_speed_factor;
            before.rotation_lerp_amount          = my_hitme.my_ai.rotation_lerp_amount;
            before.speed        = my_hitme.my_ai.speed;
            before.defenses     = CloneUtil.copyList <Defense>(my_hitme.stats.defenses);
            before.linear_drag  = my_hitme.my_rigidbody.drag;
            before.angular_drag = my_hitme.my_rigidbody.angularDrag;
        }
        ChangeMe(false);

        return(true);
    }
Example #13
0
 private void _ReturnToNormal()
 {//probably going overboard with copy
     my_hitme.stats.inventory = CloneUtil.copyList(original_wish_list);
 }
Example #14
0
    public float Init(HitMe _hitme, float[] stats)
    {
        percent_increase = Get.getPercent(stats[0]);
        lifetime         = stats[1];
        my_time          = 0;
        _hitme.EnableVisuals(MonsterType.Wishful, lifetime);

        if (is_active)
        {
            return(percent_increase);
        }

        my_hitme  = _hitme;
        is_active = true;


        // Debug.Log("initializing wish catcher: percent increase " + percent_increase + " for " + lifetime + "\n");
        original_wish_list = new List <Wish>();



        finisher_percent = (stats.Length == StaticStat.StatLength(EffectType.WishCatcher, true)) ? stats[2] : 0;

        bool finisher = (finisher_percent > 0 && UnityEngine.Random.RandomRange(0, 1) < finisher_percent);

        if (finisher)
        {
            lifetime = stats[1] * 2f;        //some other stuff as well like add health and other nice wishes
        }
        original_wish_list = CloneUtil.copyList(_hitme.stats.inventory);

        bool have_health = false;
        bool have_damage = false;
        bool have_dreams = false;

        Debug.Log("Wishcatcher " + stats[0] + " -> " + percent_increase + "\n");
        foreach (Wish w in _hitme.stats.inventory)
        {
            w.percent *= (1 + percent_increase);
            //  Debug.Log("Setting " + _hitme.gameObject.name + " " + w.type + " to " + w.strength + "\n");
            if (finisher)
            {
                w.percent *= (1 + finisher_percent);
                if (w.type == WishType.MoreHealth)
                {
                    have_health = true;
                }
                if (w.type == WishType.MoreDreams)
                {
                    have_dreams = true;
                }
                if (w.type == WishType.MoreDamage)
                {
                    have_damage = true;
                }
            }
        }

        if (finisher && !have_health)
        {
            _hitme.stats.inventory.Add(new Wish(WishType.MoreHealth, 1, finisher_percent));
        }
        if (finisher && !have_dreams)
        {
            _hitme.stats.inventory.Add(new Wish(WishType.MoreDreams, 0.25f, finisher_percent));
        }
        if (finisher && !have_damage)
        {
            _hitme.stats.inventory.Add(new Wish(WishType.MoreDamage, 0.25f, finisher_percent));
        }

        return(percent_increase);
    }