Exemplo n.º 1
0
        public ErraticStrategy(IAIEntity controlled, int shootCooldown) : base(controlled, shootCooldown)
        {
            turnCooldown = 5000;

            cdHandler = new CooldownHandler(Util.Rand(turnCooldown));
            cdHandler.StartCooldown();
        }
Exemplo n.º 2
0
 public NumberPopup(string id, int points, Point2D refPos, List <Color> colors, float vel,
                    Vector dir, float lifetime, BoundaryStrategy boundaryStrat, Team team, bool optimiseMe
                    ) : base(id, null, refPos, SwinGame.PointAt(0, 0), null, colors, 0, dir.Multiply(vel), dir, boundaryStrat, team, optimiseMe)
 {
     text      = $"+{points}";
     cdHandler = new CooldownHandler(lifetime * 1000);
     cdHandler.StartCooldown();
 }
Exemplo n.º 3
0
        /// <summary>
        /// initialise an ammo object
        /// </summary>
        /// <param name="pos">spawning position</param>
        /// <param name="dir">spawning direction</param>
        /// <param name="vel">spawning velocity</param>
        public virtual void Init(Point2D pos, Vector dir, Vector vel)
        {
            //set position and direction of ammo to that of the passed in parent entity
            TeleportTo(pos);
            theta = Dir.AngleTo(dir) * Math.PI / 180;

            MaxVel   += vel.Magnitude;
            cdHandler = new CooldownHandler(lifetime * 1000);
            cdHandler.StartCooldown();
        }
Exemplo n.º 4
0
        public EmittingAmmo(string id, string filePath, Point2D refPos, Point2D offsetPos, Shape shape, List <Color> colors,
                            int mass, int damage, float lifetime, float vel, float maxVel, float primingDelay, float turnRate,
                            List <Component> emitters, BoundaryStrategy boundaryStrat, IHandlesEntities entHandler, Team team
                            ) : base(id, filePath, refPos, offsetPos, shape, colors, mass, damage, lifetime, vel, maxVel, turnRate, boundaryStrat, team)
        {
            primingTimer = new CooldownHandler(primingDelay);
            primingTimer.StartCooldown();
            this.emitters = emitters;

            entityHandler = entHandler;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Spawn a random AI ship
        /// </summary>
        private void Spawn()
        {
            Point2D          pos           = Util.RandomPointInRect(playArea);
            BoundaryStrategy boundaryStrat = new WrapBoundaryBehaviour(playArea);

            Ship aiShip = shipFac.CreateRandomShip(SwinGame.ToWorld(SwinGame.MousePosition()), boundaryStrat, ControllerType.Computer, difficulty, entityHandler);

            entityHandler.Track(aiShip);

            cdHandler.StartCooldown();
        }
Exemplo n.º 6
0
        public AISpawner(Difficulty diff, Rectangle playArea, ShipFactory shipFactory, IHandlesEntities entHandler)
        {
            entityHandler = entHandler;
            shipFac       = shipFactory;
            difficulty    = diff;

            this.playArea = playArea;

            cdHandler = new CooldownHandler(diff.SpawnTimer * 1000);
            cdHandler.StartCooldown();
        }
Exemplo n.º 7
0
        public Debris(string id, string filePath, Point2D refPos, Point2D offsetPos, Shape shape,
                      List <Color> colors, BoundaryStrategy boundaryStrat, int health, Vector vel, Vector dir,
                      float friction, float turnRate, float lifetime, Team team
                      ) : base(id, filePath, refPos, offsetPos, shape, colors, health, vel, dir, boundaryStrat, team)
        {
            this.friction = friction;
            this.turnRate = turnRate;

            cdHandler = new CooldownHandler(lifetime * 1000);
            cdHandler.StartCooldown();
        }
Exemplo n.º 8
0
        /// <summary>
        /// Create, initialise, and track new particle
        /// </summary>
        public void Activate()
        {
            if (!cdHandler.IsOnCooldown())
            {
                JObject particleObj = Util.Deserialize(Particle.FilePath);

                Particle newParticle = new ParticleFactory().Create(particleObj, FilePath, entHandler, boundaryStrat, Team, offsetPos) as Particle;

                newParticle.Init(refPos, Dir);
                entHandler.Track(newParticle);
                cdHandler.StartCooldown();
            }
        }
Exemplo n.º 9
0
 public Tool(
     string id, string filePath, Point2D refPos, Point2D offsetPos, Shape shape,
     List <Color> colors, int health, Vector vel, Vector dir, float cooldown, BoundaryStrategy boundaryStrat,
     Team team, List <Component> children, int mass, IHandlesEntities entHandler
     ) : base(id, filePath, refPos, offsetPos, shape, colors, health, vel, dir, boundaryStrat, team)
 {
     this.cooldown   = cooldown;
     this.mass       = mass <= 0 ? 1 : mass;
     childComponents = children;
     this.entHandler = entHandler;
     cdHandler       = new CooldownHandler(cooldown * 1000);
     cdHandler.StartCooldown();
 }
Exemplo n.º 10
0
        /// <summary>
        /// activate the tool and fire it's ammo
        /// </summary>
        public void Activate()
        {
            if (!cdHandler.IsOnCooldown())
            {
                JObject ammoObj = Util.Deserialize(Ammo.FilePath);

                Ammo newAmmo = new AmmoFactory().Create(ammoObj, FilePath, entHandler, boundaryStrat, Team, SwinGame.PointAt(0, 0)) as Ammo;
                newAmmo.TeleportTo(RealPos);

                newAmmo.Init(RealPos, Dir, Vel);
                entHandler.Track(newAmmo);
                cdHandler.StartCooldown();
            }
        }
Exemplo n.º 11
0
        protected void Shoot()
        {
            //guard
            if (shootCooldown == null)
            {
                return;
            }

            if (!shootCooldown.IsOnCooldown())
            {
                controlled.Fire();
                shootCooldown.StartCooldown();
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Initialise the particle
        /// </summary>
        /// <param name="pos">spawning position</param>
        /// <param name="dir">spawning direction</param>
        public void Init(Point2D pos, Vector dir)
        {
            thrustForce = Util.RandomInRange(velRange);
            turnRate    = Util.RandomInRange(turnRateRange);
            lifetime    = Util.RandomInRange(lifetimeRange);
            cdHandler   = new CooldownHandler(lifetime * 1000);
            cdHandler.StartCooldown();

            TeleportTo(pos);
            double theta = Dir.AngleTo(dir) * Math.PI / 180;

            this.theta = theta;

            Vector deltaV = dir.Multiply(-thrustForce);

            Vel = (Vel.AddVector(deltaV)).LimitToMagnitude(thrustForce);
        }
Exemplo n.º 13
0
 protected void TakeCostCoolDown(float cooldown, int attack)
 {
     cooldownHandler.StartCooldown(attack, cooldown);
 }