예제 #1
0
        void OnPlayerAttack(BasePlayer attacker, HitInfo hitInfo)
        {
            if (!(hitInfo.HitEntity is BasePlayer))
            {
                return;
            }
            if (hitInfo.damageTypes.GetMajorityDamageType() != DamageType.Explosion)
            {
                return;
            }

            BasePlayer victim = (hitInfo.HitEntity as BasePlayer);

            if (victim != null)
            {
                RaidBehavior victimBehavior   = victim.GetComponent <RaidBehavior>();
                RaidBehavior attackerBehavior = attacker.GetComponent <RaidBehavior>();

                if (victimBehavior != null && victimBehavior.raid != null)
                {
                    if (attackerBehavior == null || (attackerBehavior != null && attackerBehavior.raid == null))
                    {
                        AddToRaid(attacker, victimBehavior.raid);
                    }
                }
            }
        }
예제 #2
0
        void RegisterKill(BasePlayer player, BasePlayer attacker)
        {
            RaidBehavior behavior = player.GetComponent <RaidBehavior>();

            if (behavior != null && behavior.raid != null)
            {
                Dictionary <ulong, int> kills;
                if (behavior.raid.kills.TryGetValue(attacker.userID, out kills))
                {
                    if (!kills.ContainsKey(player.userID))
                    {
                        kills.Add(player.userID, 1);
                    }
                    else
                    {
                        kills[player.userID]++;
                    }
                }
                else
                {
                    behavior.raid.kills.Add(attacker.userID, new Dictionary <ulong, int>()
                    {
                        { player.userID, 1 }
                    });
                }

                GameObject.Destroy(player.GetComponent <RaidBehavior>());
            }
        }
예제 #3
0
        void AddToRaid(BasePlayer player, Raid raid)
        {
            RaidBehavior behavior = player.gameObject.AddComponent <RaidBehavior>();

            behavior.raid = raid;
            if (!behavior.raid.participants.Contains(player.userID))
            {
                behavior.raid.participants.Add(player.userID);
            }
        }
예제 #4
0
        public List <Raid> GetRaids()
        {
            List <Raid> raids   = new List <Raid>();
            var         objects = GameObject.FindObjectsOfType(typeof(RaidBehavior));

            if (objects != null)
            {
                foreach (var gameObj in objects)
                {
                    RaidBehavior raidBehavior = gameObj as RaidBehavior;
                    if (raidBehavior.raid != null)
                    {
                        raids.Add(raidBehavior.raid);
                    }
                }
            }

            return(raids);
        }
예제 #5
0
        bool TryGetRaid(BasePlayer source, ulong victim, UnityEngine.Vector3 position, out Raid raid)
        {
            List <BasePlayer> nearbyTargets = new List <BasePlayer>();

            Vis.Entities <BasePlayer>(position, raidDistance, nearbyTargets, blockLayer);
            nearbyTargets = Sort(position, nearbyTargets);


            List <Raid> existingRaids = new List <Raid>();

            RaidBehavior sourceBehavior = source.GetComponent <RaidBehavior>();

            if (sourceBehavior != null && sourceBehavior.raid != null)
            {
                existingRaids.Add(sourceBehavior.raid);
            }

            if (existingRaids.Count == 0 && nearbyTargets.Count > 0)
            {
                foreach (BasePlayer nearbyTarget in nearbyTargets)
                {
                    RaidBehavior behavior = nearbyTarget.GetComponent <RaidBehavior>();
                    if (behavior != null && behavior.raid != null)
                    {
                        if (!existingRaids.Contains(behavior.raid))
                        {
                            existingRaids.Add(behavior.raid);
                        }
                    }
                }
            }

            bool found = true;

            if (existingRaids.Count == 0)
            {
                found = false;
                Raid newRaid = StartRaid(source, victim, position);
                existingRaids.Add(newRaid);
            }
            else if (sourceBehavior == null || (sourceBehavior != null && sourceBehavior.raid == null))
            {
                AddToRaid(source, existingRaids[0]);
            }

            if (nearbyTargets.Count > 0)
            {
                foreach (BasePlayer nearbyTarget in nearbyTargets)
                {
                    RaidBehavior behavior = nearbyTarget.GetComponent <RaidBehavior>();
                    if (behavior == null || (behavior != null && behavior.raid == null))
                    {
                        AddToRaid(nearbyTarget, existingRaids[0]);
                    }
                }
            }

            RefreshRaid(existingRaids[0]);

            raid = existingRaids[0];
            return(found);
        }