Exemplo n.º 1
0
        public void OnTriggerEnter(Collider other)
        {
            if (other.isTrigger)
            {
                return;                //lights will be handled elsewhere
            }
            if (mIsDispersed | mDispersing)
            {
                return;
            }

            switch (other.gameObject.layer)
            {
            case Globals.LayerNumPlayer:
                if (Vector3.Distance(Player.Local.Position, Position) > Collider.radius)
                {
                    Player.Local.Status.AddCondition("Darkrot");
                    MasterAudio.PlaySound(MasterAudio.SoundType.Darkrot, mTr, "DarkrotInfect");
                    FXManager.Get.SpawnFX(Position, "AcidShower");
                    DarkrotAmount = 0f;
                    Disperse(Mathf.Infinity);
                }
                break;

            case Globals.LayerNumWorldItemActive:
                //maybe we're Luminte?
                mIoiCheck = null;
                if (WorldItems.GetIOIFromCollider(other, out mIoiCheck) && mIoiCheck.IOIType == ItemOfInterestType.WorldItem)
                {
                    mluminiteCheck     = null;
                    mluminiteNodeCheck = null;
                    if (mIoiCheck.worlditem.Is <Luminite> (out mluminiteCheck) && !mluminiteCheck.IsDark)
                    {
                        DarkrotAmount = mluminiteCheck.AbsorbDarkrot(DarkrotAmount);
                        MasterAudio.PlaySound(MasterAudio.SoundType.Darkrot, mTr, "DarkrotAbsorb");
                    }
                    else if (mIoiCheck.worlditem.Is <LuminiteNode> (out mluminiteNodeCheck) && !mluminiteNodeCheck.IsDark)
                    {
                        DarkrotAmount = mluminiteNodeCheck.AbsorbDarkrot(DarkrotAmount);
                        MasterAudio.PlaySound(MasterAudio.SoundType.Darkrot, mTr, "DarkrotAbsorb");
                    }
                    if (DarkrotAmount <= 0f)
                    {
                        Disperse(Mathf.Infinity);
                    }
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        public void OnCollectiveThoughtStart()
        {
            IItemOfInterest ioi = creature.CurrentThought.CurrentItemOfInterest;

            if (ioi == mMeteorToGather || ioi == mLuminiteToGather || ioi == mThingToInvestigate)
            {
                return;
            }

            switch (BehaviorState)
            {
            case OrbBehaviorState.Burrowing:
            case OrbBehaviorState.Despawning:
            case OrbBehaviorState.Unpowered:
            case OrbBehaviorState.EatingLuminite:
            case OrbBehaviorState.EatingMeteor:
            default:
                return;

            case OrbBehaviorState.ConsideringOptions:
            case OrbBehaviorState.Awakening:
                if (ioi.IOIType == ItemOfInterestType.Player || ioi != null && ioi.HasAtLeastOne(ThingsOrbsFindInteresting))
                {
                    ThingToInvestigate = ioi;
                }
                break;

            case OrbBehaviorState.SeekingLuminite:
            case OrbBehaviorState.SeekingMeteor:
                if (ioi.IOIType == ItemOfInterestType.Player || ioi != null && ioi.HasAtLeastOne(ThingsOrbsFindInteresting))
                {
                    //stop and consider the thing for a moment against our other options
                    ThingToInvestigate = ioi;
                }
                BehaviorState = OrbBehaviorState.ConsideringOptions;
                break;
            }

            //see what we're doing
            if (worlditem.Is <Hostile> (out hostile))
            {
                return;
            }

            //ignore it by default
            creature.CurrentThought.Should(IOIReaction.IgnoreIt);
            if (ioi == damageable.LastDamageSource)
            {
                //always attack a threat
                creature.CurrentThought.Should(IOIReaction.KillIt, 3);
                OrbSpeak(OrbSpeakUnit.TargetIsHostileEngagingTarget, worlditem.tr);
                return;
            }
            else
            {
                //see if it's something we care about
                if (ioi.Has("Luminite"))
                {
                    Luminite luminite = ioi.worlditem.Get <Luminite> ();
                    //if we're already gathering luminite
                    if (HasLuminiteToGather)
                    {
                        if (mLuminiteToGather == luminite)
                        {
                            //d'oh, already gathering, forget it
                            return;
                        }
                        //go for the closer one
                        if (Vector3.Distance(luminite.worlditem.Position, worlditem.Position) < Vector3.Distance(LuminiteToGather.worlditem.Position, worlditem.Position))
                        {
                            LuminiteToGather = luminite;
                            BehaviorState    = OrbBehaviorState.ConsideringOptions;
                        }
                    }
                    else
                    {
                        LuminiteToGather = luminite;
                        LuminiteToGather.IncomingGatherer = this.worlditem;
                        BehaviorState = OrbBehaviorState.ConsideringOptions;
                    }
                }
                else if (ioi.Has("Meteor"))
                {
                    Meteor meteor = ioi.worlditem.Get <Meteor> ();
                    if (HasMeteorToGather)
                    {
                        if (mMeteorToGather == meteor)
                        {
                            //d'oh, already gathering, forget it
                            return;
                        }
                        //go for the closer one
                        if (Vector3.Distance(meteor.worlditem.Position, worlditem.Position) < Vector3.Distance(MeteorToGather.worlditem.Position, worlditem.Position))
                        {
                            MeteorToGather = meteor;
                            BehaviorState  = OrbBehaviorState.ConsideringOptions;
                        }
                    }
                    else
                    {
                        MeteorToGather = meteor;
                        BehaviorState  = OrbBehaviorState.ConsideringOptions;
                    }
                }
                else
                {
                    //see if it has any of the things we care about
                    if (ioi.IOIType == ItemOfInterestType.Player || ioi.HasAtLeastOne(ThingsOrbsFindInteresting))
                    {
                        ThingToInvestigate = ioi;
                        BehaviorState      = OrbBehaviorState.ConsideringOptions;
                    }
                }
            }
        }