Exemple #1
0
        public override void PopulateExamineList(System.Collections.Generic.List <WIExamineInfo> examine)
        {
            FillStackContainer fsc = null;

            if (worlditem.Has <FillStackContainer>(out fsc))
            {
                if (!fsc.State.HasBeenFilled)
                {
                    fsc.TryToFillContainer(true);
                }
            }
            WIExamineInfo e = new WIExamineInfo("It's worth $" + State.TotalValue.ToString());

            examine.Add(e);
        }
Exemple #2
0
        public override void OnInitializedFirstTime()
        {
            CheckTemplate();
            //set the states of our looker, listener, motile etc. using our template
            //this will only happen the first time the creature is created
            //after that it will pull this info from its stack item state
            Looker looker = null;

            if (worlditem.Is <Looker> (out looker))
            {
                Reflection.CopyProperties(Template.LookerTemplate, looker.State);
            }
            Listener listener = null;

            if (worlditem.Is <Listener> (out listener))
            {
                Reflection.CopyProperties(Template.ListenerTemplate, listener.State);
            }
            Motile motile = null;

            if (worlditem.Is <Motile> (out motile))
            {
                Reflection.CopyProperties(Template.MotileTemplate, motile.State);
            }
            FillStackContainer fsc = null;

            if (worlditem.Is <FillStackContainer> (out fsc))
            {
                if (string.IsNullOrEmpty(Template.Props.InventoryFillCategory))
                {
                    Template.Props.InventoryFillCategory = Creatures.Get.DefaultInventoryFillCategory;
                }
                fsc.State.WICategoryName = Template.Props.InventoryFillCategory;
            }
            //all creatures are damageable
            damageable = worlditem.Get <Damageable> ();
            damageable.ApplyForceAutomatically = false;
            if (!State.IsDead)
            {
                Reflection.CopyProperties(Template.DamageableTemplate, damageable.State);
            }
            //add each of the custom scripts in the template
            for (int i = 0; i < Template.Props.CustomWIScripts.Count; i++)
            {
                worlditem.Add(Template.Props.CustomWIScripts [i]);
            }
            //and we're done!
        }
Exemple #3
0
        public override void OnInitialized()
        {
            CharacterBody body = (CharacterBody)mBody;

            body.HairLength = State.HairLength;
            body.HairColor  = State.HairColor;

            animator = Body.GetComponent <CharacterAnimator> ();

            worlditem.OnGainPlayerFocus += OnGainPlayerFocus;
            worlditem.OnAddedToGroup    += OnAddedToGroup;
            worlditem.OnScriptAdded     += OnScriptAdded;
            worlditem.HudTargeter        = new HudTargetSupplier(HudTargeter);
            worlditem.OnPlayerCollide   += OnPlayerCollide;
            //set this so the body has something to lerp to
            if (mBody != null)
            {
                //this tells the body what to follow
                Motile motile = null;
                if (worlditem.Is <Motile> (out motile))
                {
                    if (Template.TemplateType == CharacterTemplateType.UniquePrimary || Template.TemplateType == CharacterTemplateType.UniqueAlternate)
                    {
                        motile.State.MotileProps.UseKinematicBody = false;
                    }
                    motile.BaseAction.WalkingSpeed = true;
                    mBody.OnSpawn(motile);
                }
                else
                {
                    mBody.OnSpawn(this);
                }
                mBody.transform.parent = worlditem.Group.transform;
                mBody.name             = worlditem.FileName + "-Body";
                mBody.Initialize(worlditem);
                if (State.Flags.Gender == 1)
                {
                    mBody.Sounds.MotionSoundType = MasterAudio.SoundType.CharacterVoiceMale;
                }
                else
                {
                    mBody.Sounds.MotionSoundType = MasterAudio.SoundType.CharacterVoiceFemale;
                }
            }

            Container container = null;

            if (worlditem.Is <Container> (out container))
            {
                container.CanOpen      = false;
                container.CanUseToOpen = false;
                container.OpenText     = "Search";
                FillStackContainer fillStackContainer = worlditem.Get <FillStackContainer> ();
                fillStackContainer.State.Flags    = State.Flags;
                fillStackContainer.State.FillTime = ContainerFillTime.OnOpen;
            }

            Looker looker = null;

            if (worlditem.Is <Looker> (out looker))
            {
                looker.OnSeeItemOfInterest += OnSeeItemOfInterest;
            }
            Listener listener = null;

            if (worlditem.Is <Listener> (out listener))
            {
                listener.OnHearItemOfInterest += OnHearItemOfInterest;
            }

            damageable = worlditem.Get <Damageable> ();
            damageable.State.Result          = DamageableResult.Die;
            damageable.OnTakeDamage         += OnTakeDamage;
            damageable.OnTakeCriticalDamage += OnTakeCriticalDamage;
            damageable.OnTakeOverkillDamage += OnTakeOverkillDamage;
            damageable.OnDie += OnDie;

            mFollowAction            = new MotileAction();
            mFollowAction.Name       = "Follow action by Character";
            mFollowAction.Type       = MotileActionType.FollowTargetHolder;
            mFollowAction.Expiration = MotileExpiration.TargetOutOfRange;
            mFollowAction.Range      = 10f;

            mSleepAction            = new MotileAction();
            mSleepAction.Name       = "Sleep action by Character";
            mSleepAction.Type       = MotileActionType.Wait;
            mSleepAction.Expiration = MotileExpiration.Never;
            mSleepAction.Range      = 10f;

            mFleeThreatAction               = new MotileAction();
            mFleeThreatAction.Name          = "Flee threat action by Character";
            mFleeThreatAction.Type          = MotileActionType.FleeGoal;
            mFleeThreatAction.Expiration    = MotileExpiration.TargetOutOfRange;
            mFleeThreatAction.YieldBehavior = MotileYieldBehavior.DoNotYield;
            mFleeThreatAction.OutOfRange    = 10f;
            mFleeThreatAction.Range         = Looker.AwarenessDistanceTypeToVisibleDistance(Template.LookerTemplate.AwarenessDistance);

            mPursueGoalAction               = new MotileAction();
            mPursueGoalAction.Name          = "Pursue goal action by Character";
            mPursueGoalAction.Type          = MotileActionType.FollowGoal;
            mPursueGoalAction.Expiration    = MotileExpiration.TargetInRange;
            mPursueGoalAction.YieldBehavior = MotileYieldBehavior.YieldAndWait;
            mPursueGoalAction.Range         = Template.MotileTemplate.MotileProps.RVORadius * 1.5f;

            mFocusAction               = new MotileAction();
            mFocusAction.Name          = "Focus action by Character";
            mFocusAction.Type          = MotileActionType.FocusOnTarget;
            mFocusAction.Expiration    = MotileExpiration.TargetOutOfRange;
            mFocusAction.RTDuration    = 5f;
            mFocusAction.Range         = 10f;
            mFocusAction.OutOfRange    = 15f;
            mFocusAction.WalkingSpeed  = true;
            mFocusAction.YieldBehavior = MotileYieldBehavior.YieldAndFinish;
        }