示例#1
0
        internal override void Update(int x, int y)
        {
            if (cooldown == null)
            {
                cooldown = new CooldownTimer(30);
            }

            BoundedFloat buffer = new BoundedFloat(0, 0, cost);

            CachePowerLevels();

            if (powerinL + powerinR + powerinD + powerinU >= buffer.max)
            {
                BoundedFloat.MoveVals(ref powerinL, ref buffer, powerinL);
                BoundedFloat.MoveVals(ref powerinR, ref buffer, powerinR);
                BoundedFloat.MoveVals(ref powerinD, ref buffer, powerinD);
                BoundedFloat.MoveVals(ref powerinU, ref buffer, powerinU);
            }

            EmptyInputs();

            if (buffer.IsFull())
            {
                state = true;

                var pos      = new Vector2(x - range, y - range);
                var size     = new Vector2(2 * range, 2 * range);
                var entities = EntityManager.GetEntitiesAt(pos, size, e => !(e is AutoDart || e is Player || e.data.invulnerable));

                if (cooldown.Ready())
                {
                    if (entities.Length > 0)
                    {
                        cooldown.Reset();

                        var e      = entities[MathUtil.RandInt(Program.Rand, 0, entities.Length - 1)];
                        var darvel = e.data.pos - new Vector2(x, y);
                        darvel = darvel.Normalize();
                        var dartpos = new Vector2(x, y);
                        dartpos += 1.5f * darvel;
                        darvel  /= 10;
                        var ad = new AutoDart(dartpos, darvel);
                        if (!ad.IsCollidingWithTerrain())
                        {
                            EntityManager.AddEntity(ad);
                        }
                    }
                    else
                    {
                        cooldown.SetTime(-100);
                    }
                }
            }
            else
            {
                state = false;
            }

            Terrain.TileAt(x, y).enumId = state ? TileID.AutoShooterOn : TileID.AutoShooterOff;
        }
示例#2
0
        internal override void Update(int x, int y)
        {
            if (cooldown == null)
            {
                cooldown = new CooldownTimer(40);
            }

            BoundedFloat buffer = new BoundedFloat(0, 0, cost);

            CachePowerLevels();

            if (powerinL + powerinR + powerinU + powerinD >= buffer.max)
            {
                BoundedFloat.MoveVals(ref powerinL, ref buffer, powerinL);
                BoundedFloat.MoveVals(ref powerinR, ref buffer, powerinR);
                BoundedFloat.MoveVals(ref powerinU, ref buffer, powerinU);
                BoundedFloat.MoveVals(ref powerinD, ref buffer, powerinD);
            }

            EmptyInputs();

            if (buffer.IsFull())
            {
                state = true;
                if (cooldown.Ready())
                {
                    HashSet <Vector2i> done;
                    if (PushTilesHelper(x, y, out done))
                    {
                        var list = done.ToList();
                        list.Sort(new TilePositionComparer());
                        foreach (var v in list)
                        {
                            //here
                            Terrain.MoveTile(v.x, v.y, rotation);
                        }
                        cooldown.Reset();
                    }
                }
            }
            else
            {
                state = false;
            }

            Terrain.TileAt(x, y).enumId = state ? TileID.TilePusherOn : TileID.TilePusherOff;
        }
示例#3
0
        internal override void Update(int x, int y)
        {
            BoundedFloat buffer = new BoundedFloat(0, 0, cost);

            CachePowerLevels();

            BoundedFloat.MoveVals(ref powerinL, ref buffer, powerinL.val);
            BoundedFloat.MoveVals(ref powerinR, ref buffer, powerinR.val);
            BoundedFloat.MoveVals(ref powerinU, ref buffer, powerinU.val);
            BoundedFloat.MoveVals(ref powerinD, ref buffer, powerinD.val);

            EmptyInputs();

            state = buffer.IsFull();

            Terrain.TileAt(x, y).enumId = state ? TileID.LogicLampOn : TileID.LogicLampOff;
        }
示例#4
0
        internal override void Update(int x, int y)
        {
            if (entityCage == null)
            {
                entityCage = new EntityCage(new Vector2(x, y + 1));
                EntityManager.AddEntity(entityCage);
            }

            if (cooldown == null)
            {
                cooldown = new CooldownTimer(100);
            }

            BoundedFloat buffer = new BoundedFloat(0, 0, cost);

            CachePowerLevels();

            if (powerinL + powerinR + powerinD >= buffer.max)
            {
                BoundedFloat.MoveVals(ref powerinL, ref buffer, powerinL);
                BoundedFloat.MoveVals(ref powerinR, ref buffer, powerinR);
                BoundedFloat.MoveVals(ref powerinD, ref buffer, powerinD);
            }

            EmptyInputs();

            if (buffer.IsFull())
            {
                state = true;
                if (cooldown.Ready())
                {
                    Spawn(x, y);
                    cooldown.Reset();
                }
            }
            else
            {
                state = false;
            }

            Terrain.TileAt(x, y).enumId = state ? TileID.EntitySpawnerOn : TileID.EntitySpawnerOff;
        }