Beispiel #1
0
        public void OnDamageRobot(RobotAnimation ActiveRobot, RobotAnimation TargetRobot, int Damage, Vector2 Position, bool IsPlayerControlled)
        {
            if (Owner.IsServer)
            {
                int LayerIndex = Owner.ListLayer.IndexOf(this);
                Owner.OnlineServer.SharedWriteBuffer.ClearWriteBuffer();

                Owner.OnlineServer.SharedWriteBuffer.WriteScript(new SendPlayerDamageScriptServer(LayerIndex, ActiveRobot.ID, TargetRobot.ID, Position,
                                                                                                  Damage, TargetRobot.HP, IsPlayerControlled));

                foreach (IOnlineConnection ActivePlayer in Owner.GameGroup.Room.ListOnlinePlayer)
                {
                    ActivePlayer.SendWriteBuffer();
                }

                if (TargetRobot.HP <= 0)
                {
                    Owner.Rules.OnKill(ActiveRobot, TargetRobot);

                    if (IsPlayerControlled)
                    {
                        TargetRobot.RespawnTimer = Owner.RespawnTime;
                    }
                    else
                    {
                        ListRobotToRemove.Add(TargetRobot.ID);
                    }
                }
            }
            else
            {
                Owner.AddDamageNumber(new DamageNumber(Position, Damage, 1000));
                Owner.PlayerSFXGenerator.PlayGetHitSound();

                if (TargetRobot.HP <= 0)
                {
                    Owner.Rules.OnKill(ActiveRobot, TargetRobot);

                    if (Owner.IsMainCharacter(TargetRobot.ID))
                    {
                        TargetRobot.RespawnTimer = Owner.RespawnTime;
                        Owner.AddKillMessage(true, true, TargetRobot.Name);
                    }
                    else if (IsPlayerControlled)
                    {
                        TargetRobot.RespawnTimer = Owner.RespawnTime;
                    }
                    else
                    {
                        ListRobotToRemove.Add(TargetRobot.ID);
                        Owner.AddKillMessage(true, false, TargetRobot.Name);
                    }

                    TargetRobot.UpdateSkills(TripleThunderRobotRequirement.OnDestroyedName);
                }
            }
        }