コード例 #1
0
ファイル: Creatures.cs プロジェクト: yazici/FRONTIERS
        public static bool SpawnCreature(CreatureDen den, WIGroup group, Vector3 spawnPosition, bool isDead, string causeOfDeath, float timeSinceDeath, out Creature newCreature)
        {
            if (Globals.MissionDevelopmentMode)
            {
                //we don't care about creatures in mission dev mode
                newCreature = null;
                return(false);
            }

            newCreature = null;
            CreatureTemplate template = null;

            if (mTemplateLookup.TryGetValue(den.State.NameOfCreature.ToLower().Trim(), out template))
            {
                WorldItem newCreatureWorldItem = null;
                if (WorldItems.CloneFromPrefab(Get.CreatureBase.GetComponent <WorldItem> (), group, out newCreatureWorldItem))
                {
                    //since this is the first time the creature is spawned
                    //it has no idea what it is
                    //so before we send it back we're going to set its template name
                    newCreature = newCreatureWorldItem.gameObject.GetOrAdd <Creature> ();
                    newCreature.State.TemplateName = template.Name;
                    newCreature.Template           = template;
                    if (isDead)
                    {
                        Debug.Log("Spawning dead creature");
                        newCreature.State.IsDead = true;
                        Damageable damageable = newCreature.GetComponent <Damageable> ();
                        damageable.State.CauseOfDeath = causeOfDeath;
                        damageable.State.DamageTaken  = damageable.State.Durability;
                        damageable.State.TimeKilled   = WorldClock.AdjustedRealTime - timeSinceDeath;
                    }
                    else
                    {
                        newCreature.State.IsDead = false;
                    }
                    newCreature.Den = den;
                    newCreatureWorldItem.Props.Local.Transform.Position   = spawnPosition;
                    newCreatureWorldItem.Props.Local.Transform.Rotation.y = UnityEngine.Random.Range(0f, 360f);
                    //Debug.Log ("Setting position of creature to " + spawnPosition.ToString ());
                }
            }
            //and that's it! the rest will be taken care of by the creature
            return(newCreature != null);
        }
コード例 #2
0
        public IEnumerator PlayCutsceneOverTime()
        {
            double waitUntil = Frontiers.WorldClock.AdjustedRealTime + State.InitialDelay;

            while (Frontiers.WorldClock.AdjustedRealTime < waitUntil)
            {
                yield return(null);
            }
            //get the creature body - we're only using a shell here
            CreatureBody     body     = null;
            CreatureTemplate template = null;
            AnimationClip    clip     = null;

            if (Creatures.GetBody(State.CreatureBodyName, out body))
            {
                if (Creatures.GetCutsceneClip(State.CutsceneClipName, out clip))
                {
                    //create the base object and add the animation
                    //parent it under this trigger
                    CreatureCutsceneObject    = gameObject.CreateChild(State.Name + " - " + State.CreatureBodyName).gameObject;
                    CreatureCutsceneAnimation = CreatureCutsceneObject.AddComponent <Animation>();
                    CreatureCutsceneAnimation.AddClip(clip, State.CutsceneClipName);
                    //this script will implement the IBodyOwner interface
                    UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent(CreatureCutsceneObject, "Assets/Scripts/GameWorld/Triggers/TriggerDestroyedHomeCutscene.cs (45,11)", State.CutsceneScriptName);
                    IBodyOwner bodyOwner = CreatureCutsceneObject.GetComponent(typeof(IBodyOwner)) as IBodyOwner;
                    //create an empty body shell
                    GameObject creatureCutsceneBodyObject = GameObject.Instantiate(body.gameObject, transform.position, Quaternion.identity) as GameObject;
                    CreatureCutsceneBody       = creatureCutsceneBodyObject.GetComponent <CreatureBody>();
                    CreatureCutsceneBody.Owner = bodyOwner;
                    //and we're off!
                    CreatureCutsceneAnimation.Play(State.CutsceneClipName, PlayMode.StopAll);
                }
            }

            while (CreatureCutsceneObject != null)
            {
                yield return(null);
            }

            GameObject.Destroy(CreatureCutsceneBody.gameObject);

            mPlayingCutscene = false;
            yield break;
        }
コード例 #3
0
ファイル: Creatures.cs プロジェクト: yazici/FRONTIERS
        public void EditorLoadTemplates()
        {
            if (!Manager.IsAwake <Mods> ())
            {
                Manager.WakeUp <Mods> ("__MODS");
                Mods.Get.Editor.InitializeEditor();
            }

            CreatureTemplates.Clear();
            List <string> creatureTemplateNames = Mods.Get.Available("Creature");

            foreach (string creatureTemplateName in creatureTemplateNames)
            {
                CreatureTemplate creatureTemplate = null;
                if (Mods.Get.Editor.LoadMod(ref creatureTemplate, "Creature", creatureTemplateName))
                {
                    creatureTemplate.StateTemplate.TemplateName = creatureTemplate.Name;
                    CreatureTemplates.Add(creatureTemplate);
                }
            }
        }
コード例 #4
0
ファイル: Creatures.cs プロジェクト: yazici/FRONTIERS
 public static bool GetTemplate(string templateName, out CreatureTemplate template)
 {
     return(mTemplateLookup.TryGetValue(templateName.Trim().ToLower(), out template));
 }