Example #1
0
    /// <summary>
    /// Spawns an individual fish.
    /// </summary>
    private void SpawnFish(int spawnTypeIndex, Vector3 spawnLocation)
    {
        GameObject fish = pool.GetPooledObject(spawnTypeIndex);

        if (fish == null)
        {
            return;
        }
        fish.transform.position = spawnLocation;
        fish.transform.rotation = Quaternion.identity;

        LightSource  lightSource  = fish.GetComponent <LightSource>();
        AbstractFish abstractFish = fish.GetComponent <AbstractFish>();

        if (lightSource != null)
        {
            float variance = Random.Range(0, lightSource.LightEnergy.CurrentEnergy * energyVariance);
            lightSource.LightEnergy.Deplete(variance);
        }
        if (abstractFish != null)
        {
            // Override the fish's default swim direction
            abstractFish.DefaultWanderAngle = initialSwimAngle;
            abstractFish.OnActiveChange(true);
        }
        fishes.Add(fish);
        NpcID npcID = fish.GetComponent <NpcID>();

        if (npcID != null)
        {
            string identity = lightSource.LightSourceID;
            npcID.ID = identity;
        }
    }
Example #2
0
    /// <summary>
    /// Creates the pool
    /// </summary>
    public void Start()
    {
        pool = new List <GameObject> [pooledObjects.Length];
        if (!isServer)
        {
            return;
        }
        for (int i = 0; i < pooledObjects.Length; i++)
        {
            pool[i] = new List <GameObject>();
            for (int j = 0; j < pooledAmount[i]; j++)
            {
                GameObject gameobject = (GameObject)Instantiate(pooledObjects[i]);

                AbstractFish fish = gameobject.GetComponent <AbstractFish>();
                if (fish != null)
                {
                    fish.OnActiveChange(false);
                }
                else
                {
                    gameobject.SetActive(false);
                }
                pool[i].Add(gameobject);

                LightSource lightSource = gameobject.GetComponent <LightSource>();
                NpcID       npcID       = gameobject.GetComponent <NpcID>();
                if (npcID != null)
                {
                    string identity = lightSource.LightSourceID;
                    npcID.ID = identity;
                }
            }
        }
    }
Example #3
0
 public O_SUMMON_NPC()
 {
     LifeType   = 0;
     NPCID      = new NpcID();
     NPCIDType  = 0;
     Range      = 0;
     Life       = 0;
     PathID     = 0;
     PathIDType = 0;
     NPCNum     = 0;
     NPCNumType = 0;
     Target     = new TargetParam();
 }
Example #4
0
 public void Read(BinaryReader br)
 {
     LifeType = br.ReadInt32();
     NPCID    = new NpcID()
     {
         Value = br.ReadUInt32()
     };
     NPCIDType  = br.ReadInt32();
     Range      = br.ReadInt32();
     Life       = br.ReadInt32();
     PathID     = br.ReadInt32();
     PathIDType = br.ReadInt32();
     NPCNum     = br.ReadInt32();
     NPCNumType = br.ReadInt32();
     Target     = TargetStream.Read(br);
 }
Example #5
0
        public static void Initialize()
        {
            BaseTypes = new List <Type>();

            List <Type> TypeList = Assembly.GetExecutingAssembly().GetTypes()
                                   .Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(NpcBase)) && t.Namespace == "ProjectMove.Content.Npcs.NpcTypes")
                                   .ToList();

            for (ushort i = 0; i < TypeList.Count; i++)
            {
                Type type = TypeList[i];

                BaseTypes.Add(type);
                NpcID.Add(type, i);
            }
        }