Esempio n. 1
0
        public void Thrust(int thrustStrength)
        {
            Vector deltaV = Dir.Multiply(thrustForce / mass);

            deltaV = deltaV.Multiply(thrustStrength);
            Vel    = (Vel.AddVector(deltaV)).LimitToMagnitude(MaxVel);
        }
Esempio n. 2
0
        public bool TryReactToCollision(int dmg, Vector collidingVel, int collidingMass, Team collidingTeam, bool forceReaction = false)
        {
            health -= dmg;

            float velTransferMod = ((float)collidingMass / (float)Mass);

            Vel = Vel.AddVector(collidingVel.Multiply(velTransferMod));
            Vel = Vel.LimitToMagnitude(MaxVel);

            if (health <= 0)
            {
                Kill(collidingTeam);
            }

            return(true);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        /// <summary>
        /// Object's reaction to being collided with
        /// </summary>
        /// <param name="dmg">incoming damage</param>
        /// <param name="collidingVel">velocity of other object</param>
        /// <param name="collidingMass">mass of other object</param>
        /// <param name="collider">
        /// team of other object</param>
        /// <param name="forceReaction">opt to bypass hurting timeout</param>
        public virtual bool TryReactToCollision(int dmg, Vector collidingVel, int collidingMass, Team collidingTeam, bool forceReaction = false)
        {
            if (!isHurting || forceReaction)
            {
                isHurting = true;
                hurtTimer.Start();

                health -= dmg;
                float velTransferMod = ((float)collidingMass / (float)Mass);
                Vel = Vel.AddVector(collidingVel.Multiply(velTransferMod));
                Vel = Vel.LimitToMagnitude(MaxVel);

                if (health <= 0)
                {
                    Kill(collidingTeam);
                }

                return(true);
            }
            return(false);
        }