Exemplo n.º 1
0
            public void BreakWeapon(bool isExplosion)
            {
                IPlayer pl = User.GetPlayer();

                if (pl != null && !pl.IsDead)
                {
                    if (pl.CurrentWeaponDrawn == WeaponItemType.Rifle)
                    {
                        if (GlobalRandom.Next(0, 100) < (int)(WeaponBreakingChance * Armor.BreakWeaponFactor))
                        {
                            Vector2         pos    = pl.GetWorldPosition();
                            RifleWeaponItem weapon = pl.CurrentPrimaryWeapon;
                            if ((weapon.WeaponItem == WeaponItem.BAZOOKA || weapon.WeaponItem == WeaponItem.GRENADE_LAUNCHER ||
                                 weapon.WeaponItem == WeaponItem.FLAMETHROWER) && weapon.CurrentAmmo > 0 && (GlobalRandom.Next(0, 100) < WeaponExplosionChance || isExplosion))
                            {
                                GlobalGame.TriggerExplosion(pos);
                            }
                            pl.RemoveWeaponItemType(WeaponItemType.Rifle);
                            GlobalGame.PlayEffect("CFTXT", pl.GetWorldPosition(), "WEAPON BROKEN");
                            GlobalGame.CreateObject("MetalDebris00A", pos, (float)rnd.NextDouble());
                            pos.X += 5;
                            GlobalGame.CreateObject("MetalDebris00B", pos, (float)rnd.NextDouble());
                            pos.X -= 10;
                            GlobalGame.CreateObject("MetalDebris00C", pos, (float)rnd.NextDouble());
                        }
                    }
                }
            }
Exemplo n.º 2
0
            public void SpawnDrone(TPlayer player, int id)
            {
                Area  area = GlobalGame.GetCameraArea();
                float x    = GlobalRandom.Next((int)(area.Left + area.Width / 5), (int)(area.Right - area.Width / 5));
                float y    = area.Top + 10;

                CreateTurret(id, new Vector2(x, y), player.User.GetPlayer().FacingDirection, player.Team);
                GlobalGame.PlayEffect("EXP", new Vector2(x, y));
                GlobalGame.PlaySound("Explosion", new Vector2(x, y), 1.0f);
            }
Exemplo n.º 3
0
        public static void SpawnDrone(int id, PlayerTeam team)
        {
            Area  area = GlobalGame.GetCameraArea();
            float x    = GlobalRandom.Next((int)(area.Left + area.Width / 5), (int)(area.Right - area.Width / 5));
            float y    = area.Top - 10;

            CreateTurret(id, new Vector2(x, y), 1, team);
            GlobalGame.PlayEffect("EXP", new Vector2(x, y));
            GlobalGame.PlaySound("Explosion", new Vector2(x, y), 1.0f);
        }
Exemplo n.º 4
0
            public void SpawnSmokeCircle(float radius)
            {
                float angle = 0;

                while (angle < Math.PI * 2)
                {
                    float y = (float)Math.Sin(angle) * radius;
                    float x = (float)Math.Cos(angle) * radius;
                    GlobalGame.PlayEffect("STM", Position + new Vector2(x, y));
                    angle++;
                }
            }
Exemplo n.º 5
0
 public bool Update()
 {
     if (Object == null)
     {
         return(false);
     }
     if (Count <= 0)
     {
         return(false);
     }
     if (CurrentTime <= 0)
     {
         GlobalGame.PlayEffect(Id, Object.GetWorldPosition());
         CurrentTime = Time;
         Count--;
     }
     CurrentTime--;
     return(true);
 }
Exemplo n.º 6
0
            public void DrawJetPackEffect(TPlayer player)
            {
                IPlayer pl  = player.User.GetPlayer();
                Vector2 vel = pl.GetLinearVelocity();
                Vector2 pos = pl.GetWorldPosition();

                if (vel.Y < 0)
                {
                    pos.Y -= 6;
                    GlobalGame.PlayEffect("FIRE", pos + new Vector2(10, 0));
                    GlobalGame.PlayEffect("FIRE", pos - new Vector2(10, 0));
                }
                else
                {
                    pos.Y -= 8;
                    GlobalGame.PlayEffect("FIRE", pos);
                }
                GlobalGame.PlaySound("Flamethrower", pos, 1f);
            }
Exemplo n.º 7
0
 public void OnFire(TPlayer player, WeaponItemType type)
 {
     if (CanOverheat)
     {
         Overheating += ShotHeat;
         if (Overheating >= 100)
         {
             player.User.GetPlayer().RemoveWeaponItemType(type);
             GlobalGame.PlayEffect("CFTXT", player.Position, "OVERHEATED");
             GlobalGame.PlayEffect("EXP", player.Position);
             player.Hp      -= 50;
             player.Bleeding = true;
             Vector2 pos = player.Position;
             GlobalGame.CreateObject("MetalDebris00A", pos, (float)rnd.NextDouble());
             pos.X += 5;
             GlobalGame.CreateObject("MetalDebris00B", pos, (float)rnd.NextDouble());
             pos.X -= 10;
             GlobalGame.CreateObject("MetalDebris00C", pos, (float)rnd.NextDouble());
         }
         else
         {
             GlobalGame.PlayEffect("CFTXT", player.Position, "OVERHEATING " + ((int)Overheating).ToString() + "%");
         }
     }
     if (DNAProtection && player.Team != TeamDNA)
     {
         player.User.GetPlayer().RemoveWeaponItemType(type);
         GlobalGame.PlayEffect("CFTXT", player.Position, "DNA SCAN ERROR");
         GlobalGame.TriggerExplosion(player.Position);
         DNAProtection = false;
     }
     if (type == WeaponItemType.Thrown)
     {
         CreateThrownWeapon(Weapon, CustomId, player.Position);
     }
 }
Exemplo n.º 8
0
            public void Update()
            {
                if (SmokeEffectTime > 0)
                {
                    SmokeEffectTime--;
                }
                if (MainBlock.GetHealth() <= 5 && SmokeEffectTime == 0)
                {
                    GlobalGame.PlayEffect("TR_S", MainMotor.GetWorldPosition());
                    GlobalGame.PlayEffect("TR_S", MainMotor.GetWorldPosition() + new Vector2(0, 5));
                    SmokeEffectTime = 5;
                }
                TextName.SetWorldPosition(MainMotor.GetWorldPosition() + new Vector2(0, 10));
                string name = Name;

                for (int i = 0; i < WeaponList.Count; i++)
                {
                    name += "[" + WeaponList[i].Ammo + "]";
                }
                TextName.SetText(name);
                if (!HackingProtection && IsJamming(Team))
                {
                    TextName.SetTextColor(Color.White);
                    if (GlobalRandom.Next(100) <= 10)
                    {
                        string line = " ";
                        for (int i = 0; i < 10; i++)
                        {
                            switch (GlobalRandom.Next(5))
                            {
                            case 0: line += "#"; break;

                            case 1: line += "@"; break;

                            case 2: line += "%"; break;

                            case 3: line += "_"; break;

                            case 4: line += "*"; break;
                            }
                        }
                        TextName.SetText(line);
                    }
                }
                else if (Team == PlayerTeam.Independent || (!HackingProtection && IsHacking(Team)))
                {
                    TextName.SetTextColor(Color.White);
                }
                else if (Team == PlayerTeam.Team1)
                {
                    TextName.SetTextColor(new Color(122, 122, 224));
                }
                else if (Team == PlayerTeam.Team2)
                {
                    TextName.SetTextColor(new Color(224, 122, 122));
                }
                else if (Team == PlayerTeam.Team3)
                {
                    TextName.SetTextColor(new Color(112, 224, 122));
                }
                if (UpdateHealth())
                {
                    return;
                }
                UpdateWeapon();
                if (!HaveAmmo() || (IsJamming(Team) && !HackingProtection))
                {
                    return;
                }
                if (LastTargetFinding == 0)
                {
                    PlayerTeam team = Team;
                    if (IsHacking(Team) && !HackingProtection)
                    {
                        team = PlayerTeam.Independent;
                    }
                    List <IObject> targetList;
                    if (IsProtector)
                    {
                        targetList = GetFriendList(team, MainMotor.GetWorldPosition(), GetMaxDistance());
                    }
                    else
                    {
                        targetList = GetTargetList(team, MainMotor.GetWorldPosition(), GetMaxDistance(), CanHitTurret(), HackingProtection);
                    }
                    Target       = null;
                    TargetVision = 3;
                    for (int i = 0; i < targetList.Count; i++)
                    {
                        IObject obj = targetList[i];
                        if (obj == MainMotor)
                        {
                            continue;
                        }
                        if (RotationLimit > 0)
                        {
                            float angle = TwoPointAngle(MainMotor.GetWorldPosition(), obj.GetWorldPosition());
                            if (Math.Abs(GetAngleDistance(angle, DefaultAngle + MainMotor.GetAngle())) > RotationLimit)
                            {
                                continue;
                            }
                        }
                        int trace = TraceToObject(obj);
                        if (trace < TargetVision)
                        {
                            TargetVision = trace;
                            Target       = obj;
                            break;
                        }
                    }
                    LastTargetFinding = 10;
                }
                else
                {
                    LastTargetFinding--;
                }
                if (EnableMovement)
                {
                    if (Target != null && (MainMotor.GetWorldPosition() - Target.GetWorldPosition()).Length() <= DroneMinDistance && CanFire)
                    {
                        CurrentPath.Clear();
                        StopMovement();
                    }
                    else if (LastPathFinding == 0)
                    {
                        CurrentPath.Clear();
                        StopMovement();
                        FindPathToTarget(randomTarget: ChangingRoute);
                        LastPathFinding = 200;
                    }
                    if (LastPathFinding > 0)
                    {
                        LastPathFinding--;
                    }
                    Movement();
                }
                if (Target == null)
                {
                    MainMotor.SetMotorSpeed(0);
                    return;
                }
                Vector2 targetPos = Target.GetWorldPosition();

                if (IsPlayer(Target.Name))
                {
                    targetPos = GetPlayerCenter((IPlayer)Target);
                }
                float targetAngle = TwoPointAngle(MainMotor.GetWorldPosition(), targetPos);

                targetAngle = GetAngleDistance(targetAngle, MainBlockAngle + MainBlock.GetAngle());


                if (Math.Abs(targetAngle) > 0.01f * RotationSpeed)
                {
                    if (targetAngle > 0)
                    {
                        MainMotor.SetMotorSpeed(RotationSpeed);
                    }
                    else
                    {
                        MainMotor.SetMotorSpeed(-RotationSpeed);
                    }
                }
                else
                {
                    MainMotor.SetMotorSpeed(0);
                    MainBlock.SetAngle(MainBlock.GetAngle() + targetAngle);

                    var startPos = MainMotor.GetWorldPosition();
                    var endPos   = targetPos;
                    Game.DrawLine(startPos, endPos, Color.Red);
                    var rci = new RayCastInput()
                    {
                        // doesn't include the objects that are overlaping the source of the raycast (the drone)
                        IncludeOverlap = true,
                        // only look at the closest hit
                        ClosestHitOnly = false,
                        // mark as hit the objects that projectiles hit
                        ProjectileHit = RayCastFilterMode.True,
                        // mark as hit the objects that absorb the projectile
                        AbsorbProjectile = RayCastFilterMode.Any
                    };

                    var raycastResult = Game.RayCast(startPos, endPos, rci);

                    foreach (var result in raycastResult)
                    {
                        Game.DrawCircle(result.Position, 1f, Color.Yellow);
                        Game.DrawLine(result.Position, result.Position + result.Normal * 5f, Color.Yellow);
                        Game.DrawArea(result.HitObject.GetAABB(), Color.Yellow);
                        Game.DrawText((MainMotor.GetWorldPosition() - Target.GetWorldPosition()).Length().ToString(), result.Position, Color.Green);
                        var raycastResultPlayersCount = raycastResult.Where(r => r.IsPlayer).Count();

                        if (raycastResult.Length > 2 + raycastResultPlayersCount && (MainMotor.GetWorldPosition() - Target.GetWorldPosition()).Length() <= 50)
                        {
                            // if there's more than 2 objects between drone and player, don't shoot
                            // and choose another target
                            ChangingRoute = true;
                            IPlayer ply = Target as IPlayer;
                            if (ply == null)
                            {
                                continue;
                            }
                            var originalTarget  = Target;
                            var possibleTargets = PlayerList.Where(pl => pl.Team != Team && !pl.Name.Equals(ply.Name));
                            var i      = GlobalRandom.Next(0, possibleTargets.Count());
                            var player = possibleTargets.ElementAt(i);
                            Target = player.Body;
                            DebugLogger.DebugOnlyDialogLog("Target changed from " + ply.Name + " to " + player.Name);
                            break;
                        }
                        else if (result.Hit &&
                                 !(raycastResult.Length > 2 + raycastResultPlayersCount) &&
                                 (result.IsPlayer ||
                                  result.HitObject.Name.IndexOf("crab", StringComparison.OrdinalIgnoreCase) >= 0 ||
                                  result.HitObject.Name.IndexOf("computer", StringComparison.OrdinalIgnoreCase) >= 0))
                        {
                            CanFire       = true;
                            ChangingRoute = false;
                            // no obstacles in the way, fire!
                            Fire(TargetVision);
                        }
                        else
                        {
                            CanFire = false;
                        }

                        if (result.Fraction < 0.3f && result.HitObject.Name.IndexOf("glass", StringComparison.OrdinalIgnoreCase) >= 0)
                        {
                            result.HitObject.Destroy();
                        }
                    }
                }
            }
Exemplo n.º 9
0
 private void PlayExplosionVisualEffects()
 {
     GlobalGame.PlayEffect("EXP", Position);
     GlobalGame.PlayEffect("S_P", Position);
     GlobalGame.PlayEffect("S_P", Position);
 }
Exemplo n.º 10
0
            public void Update()
            {
                if (!IsActive())
                {
                    return;
                }
                for (int i = 0; i < Equipment.Count; i++)
                {
                    if (Equipment[i].Id == 0)
                    {
                        Equipment.RemoveAt(i);
                        i--;
                    }
                    else
                    {
                        Equipment[i].Update(this);
                    }
                }
                IPlayer pl = null;

                if (User != null)
                {
                    pl = User.GetPlayer();
                }
                if (pl != null && (pl.RemovalInitiated || pl.IsRemoved))
                {
                    pl = null;
                }
                if (pl != null && pl.GetProfile().Name == "CPU")
                {
                    pl.Remove();
                    ActiveStatus = false;
                    return;
                }
                if (pl != null)
                {
                    Position = pl.GetWorldPosition();
                    WeaponTrackingUpdate(false);
                    var heavyWeapon = pl.CurrentPrimaryWeapon.WeaponItem;
                    if (ExtraHeavyAmmoWeapon.Contains(heavyWeapon) && pl.CurrentPrimaryWeapon.CurrentAmmo < (pl.CurrentPrimaryWeapon.MaxTotalAmmo / 2) && HasExtraHeavyAmmo)
                    {
                        pl.GiveWeaponItem(heavyWeapon);
                        HasExtraHeavyAmmo = false;
                    }
                }
                if (pl != null && Status >= 0)
                {
                    if (Status == 0)
                    {
                        StatusDisplay.SetWorldPosition(Position + new Vector2(0, 37));
                    }
                    else
                    {
                        StatusDisplay.SetWorldPosition(Position + new Vector2(0, 15));
                    }
                    pl.SetNametagVisible(InSmoke <= 0);
                    bool wasBleeding         = Bleeding;
                    IPlayerStatistics stat   = pl.Statistics;
                    float             lastHp = Hp;
                    if (ProjectileDamageTaken < stat.TotalProjectileDamageTaken)
                    {
                        float ch = stat.TotalProjectileDamageTaken - ProjectileDamageTaken;
                        ProjectileDamageTaken = stat.TotalProjectileDamageTaken;
                        //ch *= ProjectileDamageFactor * Armor.ProjectileDamageFactor;
                        if (InSmoke > 0)
                        {
                            ch *= 0.25f;
                        }
                        if (ch < Armor.MaxProjectileDamageCut && ch > Armor.MaxProjectileDamage)
                        {
                            ch = Armor.MaxProjectileDamage;
                        }
                        if (ch >= StartBleedingProjectile)
                        {
                            Bleeding = true;
                        }
                        Hp -= ch;
                        if (InSmoke <= 0)
                        {
                            BreakWeapon(false);
                        }
                    }
                    if (MeleeDamageTaken < stat.TotalMeleeDamageTaken)
                    {
                        float ch = stat.TotalMeleeDamageTaken - MeleeDamageTaken;
                        MeleeDamageTaken = stat.TotalMeleeDamageTaken;
                        //ch *= MeleeDamageFactor * Armor.MeleeDamageFactor;
                        if (ch > Armor.MaxMeleeDamage)
                        {
                            ch = Armor.MaxMeleeDamage;
                        }
                        if (ch >= StartBleedingMelee)
                        {
                            Bleeding = true;
                        }
                        Hp -= ch;
                    }
                    if (ExplosionDamageTaken < stat.TotalExplosionDamageTaken)
                    {
                        float ch = stat.TotalExplosionDamageTaken - ExplosionDamageTaken;
                        ExplosionDamageTaken = stat.TotalExplosionDamageTaken;
                        //ch *= ExplosionDamageFactor * Armor.ExplosionDamageFactor;
                        if (ch >= StartBleedingProjectile)
                        {
                            Bleeding = true;
                        }
                        Hp -= ch;
                        BreakWeapon(true);
                    }
                    if (FallDamageTaken < stat.TotalFallDamageTaken)
                    {
                        float ch = stat.TotalFallDamageTaken - FallDamageTaken;
                        FallDamageTaken = stat.TotalFallDamageTaken;
                        //ch *= FallDamageFactor * Armor.FallDamageFactor;
                        Hp -= ch;
                    }
                    if (Armor.FireProtect)
                    {
                        if (pl.IsBurning)
                        {
                            pl.ClearFire();
                        }
                    }
                    else
                    {
                        if (pl.IsBurning)
                        {
                            pl.SetMaxFire();
                        }
                        if (FireDamageTaken < stat.TotalFireDamageTaken)
                        {
                            float ch = stat.TotalFireDamageTaken - FireDamageTaken;
                            FireDamageTaken = stat.TotalFireDamageTaken;
                            //ch *= FireDamageFactor * Armor.FireDamageFactor;
                            Hp -= ch;
                        }
                    }
                    if (Bleeding)
                    {
                        if (!wasBleeding && Hp > 0)
                        {
                            GlobalGame.PlayEffect("CFTXT", pl.GetWorldPosition(), "BLEEDING");
                        }
                        if (pl.IsSprinting || pl.IsRolling || pl.IsDiving || pl.IsClimbing || pl.IsMeleeAttacking || pl.IsKicking || pl.IsJumpKicking || pl.IsJumpAttacking)
                        {
                            Hp -= HardBleeding;
                        }
                        else
                        {
                            Hp -= EasyBleeding;
                        }
                        if (JumpCount < stat.TotalJumps)
                        {
                            int ch = stat.TotalJumps - JumpCount;
                            Hp -= ch * JumpBleeding;
                        }
                        if (BleedingEffectTimer == 0)
                        {
                            Vector2 effPos = pl.GetWorldPosition();
                            effPos.Y += 6;
                            GlobalGame.PlayEffect("BLD", effPos);
                            BleedingEffectTimer = BleedingEffectPeriod;
                        }
                        if (BleedingEffectTimer > 0)
                        {
                            BleedingEffectTimer--;
                        }
                    }
                    if (IsDiving && !pl.IsDiving)
                    {
                        IsDiving = false;
                        if (DiveTime >= 45)
                        {
                            float diff = DiveHeight - pl.GetWorldPosition().Y;
                            diff -= MinDivingHeight * DivingDamageFactor * FallDamageFactor;
                            if (diff > 0)
                            {
                                Hp -= diff;
                            }
                        }
                    }
                    else if (!IsDiving && pl.IsDiving)
                    {
                        IsDiving   = true;
                        DiveTime   = 0;
                        DiveHeight = pl.GetWorldPosition().Y;
                    }
                    else if (IsDiving && pl.IsDiving)
                    {
                        DiveTime++;
                    }
                    if (IsAdrenaline)
                    {
                        float ch = (lastHp - Hp) * AdrenalineDamageFactor;
                        DelayedDamage += (lastHp - Hp) - ch;
                        Hp             = lastHp - ch;
                    }
                    else if (DelayedDamage > 0)
                    {
                        if (DamageDelaySpeed > DelayedDamage)
                        {
                            Hp           -= DelayedDamage;
                            DelayedDamage = 0;
                        }
                        else
                        {
                            Hp            -= DamageDelaySpeed;
                            DelayedDamage -= DamageDelaySpeed;
                        }
                    }
                    WeaponItem heavyWeapon = pl.CurrentPrimaryWeapon.WeaponItem;
                    if (heavyWeapon == WeaponItem.M60 || heavyWeapon == WeaponItem.GRENADE_LAUNCHER || heavyWeapon == WeaponItem.BAZOOKA || heavyWeapon == WeaponItem.SNIPER || Armor.Heavy)
                    {
                        IsSlow = true;
                    }



                    else
                    {
                        IsSlow = false;
                    }
                    if (IsSlow)
                    {
                        PlayerModifiers mods = pl.GetModifiers();
                        mods.MaxEnergy              = 0;
                        mods.MeleeStunImmunity      = 1;
                        mods.EnergyRechargeModifier = 0;
                        if (Armor.Heavy)
                        {
                            mods.SizeModifier = 1.15f;
                        }
                        pl.SetModifiers(mods);
                    }
                    if (IsSlow && ((heavyWeapon == WeaponItem.M60 || heavyWeapon == WeaponItem.GRENADE_LAUNCHER || heavyWeapon == WeaponItem.BAZOOKA || heavyWeapon == WeaponItem.SNIPER) && Armor.Heavy))
                    {
                        PlayerModifiers mods = pl.GetModifiers();
                        mods.MaxEnergy              = 0;
                        mods.MeleeStunImmunity      = 1;
                        mods.EnergyRechargeModifier = 0;
                        mods.RunSpeedModifier       = 0.5f;
                        mods.MeleeForceModifier     = 2f;
                        mods.SizeModifier           = 2.6f;

                        pl.SetModifiers(mods);
                        if (pl.IsRolling || pl.IsDiving)
                        {
                            Vector2 vel = pl.GetLinearVelocity() / 3;
                            vel.Y = 0;
                            pl.SetWorldPosition(Position - vel);
                            if (SlowEffectTimer == 0)
                            {
                                SlowEffectTimer = -1;
                            }
                        }
                        if (SlowTimer == 0 && pl.IsSprinting)
                        {
                            SlowTimer = 4;
                            if (SlowEffectTimer == 0)
                            {
                                SlowEffectTimer = -1;
                            }
                        }
                        if (SlowTimer <= 2)
                        {
                            pl.SetInputEnabled(true);
                        }
                        else
                        {
                            pl.SetInputEnabled(false);
                        }
                        if (SlowEffectTimer == -1)
                        {
                            GlobalGame.PlayEffect("CFTXT", pl.GetWorldPosition(), "TOO HEAVY");
                            SlowEffectTimer = 100;
                        }
                        if (SlowEffectTimer > 0)
                        {
                            SlowEffectTimer--;
                        }
                        if (SlowTimer > 0)
                        {
                            SlowTimer--;
                        }
                    }
                    else if (!pl.IsInputEnabled)
                    {
                        pl.SetInputEnabled(true);
                    }


                    JumpCount = stat.TotalJumps;
                    if (Status == 0)
                    {
                        if (StunTime > 0 && Status != 4)
                        {
                            Status = 4;
                            pl.Kill();
                        }
                        if (Hp > 0 && StunTime <= 0)
                        {
                            pl.SetHealth(pl.GetMaxHealth() * Hp / 100.0f);
                            //if (Hp < lastHp) pl.SetHealth(99 + GlobalRandom.Next(100) / 100.0f);
                            //else pl.SetHealth(100);
                            if (pl.IsWalking && !pl.IsManualAiming && !pl.IsClimbing && !pl.IsLedgeGrabbing && !pl.IsInMidAir && !pl.IsRolling)
                            {
                                if (CurrentEquipment < Equipment.Count)
                                {
                                    Equipment[CurrentEquipment].Use(this);
                                }
                            }
                            else if (Equipment.Count > 1 && pl.CurrentWeaponDrawn == WeaponItemType.NONE)
                            {
                                if (pl.IsMeleeAttacking || pl.IsJumpAttacking)
                                {
                                    CurrentEquipment = 0;
                                }
                                else if (pl.IsKicking || pl.IsJumpKicking)
                                {
                                    CurrentEquipment = 1;
                                }
                            }
                        }
                        else if (Hp <= 0)
                        {
                            if (!IsActive())
                            {
                                Status = -1;
                            }
                            else if (!pl.IsBurning || Armor.FireProtect)
                            {
                                int rnd = GlobalRandom.Next(0, 100);
                                Bleeding = false;
                                if (rnd < OvercomeChance)
                                {
                                    Hp     = OvercomeHealth;
                                    Status = 3;
                                }
                                else if (rnd < AliveChance)
                                {
                                    Hp     = StableHealth;
                                    Status = 2;
                                }
                                else if (rnd < DyingChance)
                                {
                                    Hp     = DyingHealth;
                                    Status = 1;
                                }
                                else
                                {
                                    Status = -1;
                                }
                                pl.Kill();
                            }
                            else
                            {
                                Status = -1;
                                pl.Kill();
                            }
                        }
                    }
                    else if (Status == 1 || Status == 2 || Status == 3)
                    {
                        if (pl.IsBurnedCorpse && !Armor.FireProtect)
                        {
                            Hp = 0;
                        }
                        if (Hp <= 0)
                        {
                            Status = -1;
                        }
                        else if (Hp <= DyingHealth)
                        {
                            Status = 1;
                        }
                        else if (Hp <= StableHealth)
                        {
                            Status = 2;
                        }
                        else if (Hp <= ReviveHealth)
                        {
                            Status = 3;
                        }
                    }
                    if (Status == 0)
                    {
                        StatusDisplay.SetTextColor(Color.White);
                    }
                    else
                    {
                        if (Team == PlayerTeam.Team1)
                        {
                            StatusDisplay.SetTextColor(new Color(128, 128, 255));
                        }
                        else
                        {
                            StatusDisplay.SetTextColor(new Color(255, 128, 128));
                        }
                    }
                    if (Status == 0)
                    {
                        if (CurrentEquipment < Equipment.Count && InSmoke <= 0)
                        {
                            StatusDisplay.SetText(Equipment[CurrentEquipment].GetName());
                        }
                        else
                        {
                            StatusDisplay.SetText("");
                        }
                    }
                    else if (Status == 1)
                    {
                        StatusDisplay.SetText("DYING");
                        Hp -= DyingSpeed;
                    }
                    else if (Status == 2)
                    {
                        StatusDisplay.SetText("STABLE");
                    }
                    else if (Status == 3)
                    {
                        StatusDisplay.SetText("OVERCOMING");
                        Hp += OvercomeSpeed;
                    }
                    else if (Status == 4)
                    {
                        StatusDisplay.SetText("STUN");
                        StunTime--;
                    }
                    if (Status == 3 && Hp >= ReviveHealth)
                    {
                        Revive(Hp);
                    }
                    else if (Status == 4 && StunTime <= 0)
                    {
                        Revive(Hp, Bleeding);
                    }
                }
                else if (pl == null && Status >= 0)
                {
                    Status = -1;
                }
                if (InSmoke > 0)
                {
                    InSmoke--;
                }
                if (Status == -1)
                {
                    Status = -2;
                    OnDead();
                    StatusDisplay.SetText("");
                }
            }
Exemplo n.º 11
0
 public void Update()
 {
     NeedPower = 0;
     if (CheckShieldTimer == 0)
     {
         bool d = false;
         for (int i = 0; i < PlayerList.Count; i++)
         {
             if (PlayerList[i].Team == Team)
             {
                 IPlayer pl = PlayerList[i].User.GetPlayer();
                 if (pl == null)
                 {
                     continue;
                 }
                 if (TestDistance(Position, PlayerList[i].Position, 28))
                 {
                     d = true;
                     break;
                 }
             }
         }
         if (d && !Disabled)
         {
             Remove();
             NeedPower = -2;
         }
         Disabled         = d;
         CheckShieldTimer = 30;
     }
     else if (CheckShieldTimer > 0)
     {
         CheckShieldTimer--;
     }
     if (Disabled)
     {
         return;
     }
     if (ShieldBlock == null || ShieldBlock.IsRemoved)
     {
         ShieldBlock = GlobalGame.CreateObject("InvisibleBlock", Position + new Vector2(NCos * 4, NSin * 4), Angle);
         ShieldBlock.SetSizeFactor(new Point(1, 2));
     }
     for (int i = 0; i < ShieldGlass.Count; i++)
     {
         if (ShieldGlass[i] == null)
         {
             int s = (int)Math.Pow(-1, i);
             ShieldGlass[i] = GlobalGame.CreateObject("ReinforcedGlass00A", Position + new Vector2(NCos * 4 * s, NSin * 4 * s) - new Vector2(Cos, Sin), Angle);
         }
         else if (ShieldGlass[i].IsRemoved)
         {
             ShieldGlass[i].Remove();
             ShieldGlass[i] = null;
         }
     }
     for (int i = 0; i < ShieldShard.Count; i++)
     {
         int s = (int)Math.Pow(-1, i);
         if (ShieldShard[i] == null)
         {
             ShieldShard[i] = GlobalGame.CreateObject("GlassShard00A", Position + new Vector2(NCos * 4 * s, NSin * 4 * s) + new Vector2(Cos * 4, Sin * 4), Angle - (float)Math.PI / 2);
             ShieldShard[i].SetBodyType(BodyType.Static);
         }
         else if (ShieldShard[i].IsRemoved)
         {
             ShieldShard[i].Remove();
             ShieldShard[i] = null;
             NeedPower++;
         }
     }
     if (NeedPower > 0)
     {
         int offset = GlobalRandom.Next(-8, 8);
         GlobalGame.PlayEffect("S_P", Position + new Vector2(Cos * offset, Sin * offset));
     }
     if (AnimationTime <= 0)
     {
         AnimationTime = GlobalRandom.Next(50, 150);
         int offset = GlobalRandom.Next(-8, 8);
         GlobalGame.PlayEffect("GLM", Position + new Vector2(Cos * offset, Sin * offset));
     }
     else if (AnimationTime > 0)
     {
         AnimationTime--;
     }
 }