Exemplo n.º 1
0
 public void Update()
 {
     if (Input.GetKeyDown(KeyCode.Y))
     {
         CreatureDen creatureDen = null;
         WIGroup     group       = null;
         if (Player.Local.Surroundings.IsVisitingLocation)
         {
             foreach (Location location in Player.Local.Surroundings.VisitingLocations)
             {
                 if (location.worlditem.Is <CreatureDen> (out creatureDen))
                 {
                     group = location.LocationGroup;
                     break;
                 }
             }
         }
         if (creatureDen != null)
         {
             Creature creature = null;
             Debug.Log("Spawning dead creature in den " + creatureDen.name);
             SpawnCreature(creatureDen, group, Vector3.up * 3, true, "Nothing", 0f, out creature);
             creature.worlditem.tr.parent        = group.tr;
             creature.worlditem.tr.localPosition = Vector3.up * 3;
         }
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public static bool SpawnCreature(CreatureDen den, WIGroup group, Vector3 spawnPosition, out Creature newCreature)
 {
     return(SpawnCreature(den, group, spawnPosition, false, string.Empty, 0f, out newCreature));
 }