Пример #1
0
        public bool SortSubmergedObjects(IItemOfInterest seeker, double interestInterval, out SubmergedObject subjergedObject)
        {
            subjergedObject = null;
            for (int i = SubmergedObjects.LastIndex(); i >= 0; i--)
            {
                SubmergedObject subObj = SubmergedObjects [i];
                if (subObj == null || subObj.Target == null || subObj.Target.Destroyed || (subObj.Target.IOIType == ItemOfInterestType.WorldItem && subObj.Target.worlditem.Is <WaterTrap> ()))
                {
                    SubmergedObjects.RemoveAt(i);
                }
                else
                {
                    subObj.Seeker = seeker;
                    if (subObj.Target.IOIType == ItemOfInterestType.Scenery)
                    {
                        //it's probably a fish or something
                        //there's a very low probability that we care
                        if (UnityEngine.Random.value < 0.0005f)
                        {
                            subObj.IsOfInterest = true;
                        }
                        else
                        {
                            subObj.IsOfInterest = false;
                            SubmergedObjects.RemoveAt(i);
                        }
                    }
                    else if (subObj.HasExitedWater && (WorldClock.AdjustedRealTime - subObj.TimeExitedWater) > interestInterval)
                    {
                        //just in case we're already targeting a submerged object
                        subObj.IsOfInterest = false;
                        SubmergedObjects.RemoveAt(i);
                    }
                    else if (subObj.Target.IOIType == ItemOfInterestType.Player && subObj.Target.player.IsDead)
                    {
                        subObj.IsOfInterest = false;
                        SubmergedObjects.RemoveAt(i);

                        /*} else if (subObj.Target.Position.y > mWaterHeight) {
                         * //if the target's position is higher than the water position then it can't be underwater
                         * subObj.IsOfInterest = true;
                         * SubmergedObjects.RemoveAt (i);*/
                    }
                    else
                    {
                        subObj.IsOfInterest = true;
                    }
                }
            }
            if (SubmergedObjects.Count > 0)
            {
                SubmergedObjects.Sort();
                if (SubmergedObjects [0].IsOfInterest)
                {
                    subjergedObject = SubmergedObjects [0];
                }
            }
            return(subjergedObject != null);
        }
Пример #2
0
 public bool FindPrimaryTargetObject()
 {
     if (!HasPrimaryTarget)
     {
         if (TargetSource != null)
         {
             return(TargetSource.SortSubmergedObjects(this, Globals.LeviathanRTLoseInterestInterval, out PrimaryTargetObject));
         }
         else
         {
             //start over and try to find a new one
             return(Ocean.Get.SortSubmergedObjects(this, Globals.LeviathanRTLoseInterestInterval, out PrimaryTargetObject));
         }
     }
     else if (PrimaryTargetObject.HasExitedWater && (WorldClock.AdjustedRealTime - PrimaryTargetObject.TimeExitedWater) < Globals.LeviathanRTLoseInterestInterval)
     {
         //no longer interested
         PrimaryTargetObject = null;
     }
     else if (!PrimaryTargetObject.IsOfInterest)
     {
         //no longer interested
         PrimaryTargetObject = null;
     }
     if (PrimaryTargetObject != null)
     {
         if (PrimaryTargetObject.Target.IOIType == ItemOfInterestType.Player)
         {
             //we're targeting the player
             //are we allowed to be hostile?
             if (Profile.Get.CurrentGame.Difficulty.IsDefined("NoHostileCreatures"))
             {
                 //if not, we didn't find anything
                 PrimaryTargetObject = null;
             }
             else
             {
                 //if so, alert the player
                 Player.Local.Surroundings.AddHostile(this);
             }
         }
         return(true);
     }
     return(false);
 }
Пример #3
0
    protected IEnumerator OnAttack()
    {
        //have to be careful here
        if (HasPrimaryTarget)
        {
            IItemOfInterest target = PrimaryTarget;
            transform.position    = PrimaryTarget.Position;
            mDamagePackage.Point  = MouthObject.position;
            mDamagePackage.Origin = MouthObject.position;
            SetVisible(true);
            GetComponent <Animation>().Play();
            if (Listener.IsInAudibleRange(Player.Local.Position, Position, Player.Local.AudibleRange, Globals.LeviathanMaxAudibleRange))
            {
                MasterAudio.PlaySound(MasterAudio.SoundType.Leviathan, transform, "Attack");
                MasterAudio.PlaySound(MasterAudio.SoundType.JumpLandWater, transform, "Land");
            }
            if (TargetSource != null)
            {
                FXManager.Get.SpawnFX(transform.position.WithY(TargetSource.WaterHeightAtPosition(transform.position)), "Leviathan Splash");
            }
            else
            {
                FXManager.Get.SpawnFX(transform.position.WithY(Ocean.Get.OceanSurfaceHeight), "Leviathan Splash");
            }
            mDamagePackage.Target      = target;
            mDamagePackage.InstantKill = true;
            DamageManager.Get.SendDamage(mDamagePackage);
            //pretty much a guarantee that this will instakill (TODO add instakill option to damage packages?)
            PrimaryTargetObject = null;

            while (GetComponent <Animation>().isPlaying)
            {
                yield return(null);
            }

            SetVisible(false);
        }
        mMode = HostileMode.CoolingOff;
        yield break;
    }