Пример #1
0
        public override void damage(float by, Gun.Ammo type)
        {
            base.damage(by, type);

            drop_damage += by;
            if (drop_damage > orphan_drop_damage && state == State.CAST)
            {
                for (int i = 0; i < 2; i++)
                {
                    var o = new Orphan(Vector2.zero);
                    Game.instance.orphan_group.add(o);
                    o.enterWorld(bubblePosition(i));

                    Particle pop = new Particle(AppMain.textures.skeletonkingprojectile.atlas);
                    pop.frame       = 5;
                    pop.loop        = false;
                    pop.loop_end    = 6;
                    pop.frame_speed = 0.05f;
                    pop.position    = bubblePosition(i);
                    Game.instance.particle_manager.add(pop);
                }
                state        = State.IDLE;
                idle_timeout = Util.rng.Next(idle_time_min, idle_time_max);
            }
        }
Пример #2
0
        public override void tick()
        {
            base.tick();
            if (frozenThisFrame())
            {
                return;
            }

            frame += 5;

            if (state == State.FLYING)
            {
                lerp_pos += lerp_speed;
                var smooth_lerp  = Util.smoothStep(lerp_pos);
                var new_position = origin * (1 - smooth_lerp) + destination * smooth_lerp;

                velocity = new_position - position;
                position = new_position;

                if (lerp_pos >= 1.0)
                {
                    state        = State.IDLE;
                    frame        = 0;
                    idle_timeout = (int)(Util.rng.NextFloat(idle_time_min, idle_time_max) * 60);
                }
            }

            if (state == State.IDLE)
            {
                if (--idle_timeout <= 0)
                {
                    frame = 0;
                    if (Util.rng.NextFloat() < grab_chance || Shield.existing_shield != null)
                    {
                        added_orphan = false;
                        drop_damage  = 0;
                        state        = State.GRAB;
                    }
                    else
                    {
                        state = State.LASER;
                        Choom.PlayEffect(SoundAssets.HootLaser);
                    }
                }
            }

            if (state == State.DYING)
            {
                frame += 5;
                if (frame > 1000)
                {
                    remove = true;
                }
            }

            if (state == State.GRAB)
            {
                if (frame >= 700 && !added_orphan)
                {
                    added_orphan = true;
                    int n_grabs = Util.rng.Next(min_orphans_grabbed, max_orphans_grabbed);

                    if (drop_damage > orphan_drop_damage)
                    {
                        for (int i = 0; i < n_grabs; i++)
                        {
                            var o = new Orphan(new Vector2(111 + Util.rng.Next(-40, 40), -95));
                            Game.instance.orphan_group.add(o);
                            o.enterWorld(position + o.position);
                        }
                    }
                    else
                    {
                        Game.instance.house.damage(n_grabs);
                        Choom.PlayEffect(SoundAssets.BlockLand);
                        Choom.PlayEffect(SoundAssets.OrphanTake);

                        for (int i = 0; i < n_grabs; i++)
                        {
                            held_orphans.Add(new Orphan(new Vector2(111 + Util.rng.Next(-40, 40), -95)));
                        }
                    }
                }

                if (frame >= 1000)
                {
                    frame        = 0;
                    idle_timeout = (int)(Util.rng.NextFloat(idle_time_min, idle_time_max) * 60);
                    state        = State.IDLE;
                }
            }

            if (state == State.LASER)
            {
                if (frame > 750 || Shield.existing_shield != null)
                {
                    frame        = 0;
                    idle_timeout = (int)(Util.rng.NextFloat(idle_time_min, idle_time_max) * 60);
                    state        = State.IDLE;
                }
                if (frame >= 300 && frame <= 600)
                {
                    Game.instance.damageTargetPiece(laser_damage);
                }
            }
        }