Beispiel #1
0
        public override void OnEvent(CreateNetworkedBuilding evnt)
        {
            GameObject prefab = PrefabDB.instance.GetGO(evnt.prefabID);

            if (prefab != null && evnt.requester != null)
            {
                var instance = GameObject.Instantiate(prefab);

                BoltBuilding building = instance.GetComponent <BoltBuilding>();

                building.transform.position = evnt.pos;
                building.transform.rotation = evnt.rot;

                if (!building.CheckConditions()) // check conditions serverside
                {
                    Destroy(instance);
                    return;
                }

                entities.Add(building);

                evnt.health = building.maxHealth;
                evnt.id     = entities.Count;

                building.LoadData(evnt);

                building.PackData(evnt.requester, false).Send();
            }
        }
Beispiel #2
0
        public static void LoadEntity(CreateNetworkedBuilding evnt)
        {
            GameObject prefab = PrefabDB.instance.GetGO(evnt.prefabID);

            if (prefab != null)
            {
                var instance = GameObject.Instantiate(prefab);

                BoltBuilding building = instance.GetComponent <BoltBuilding>();

                building.LoadData(evnt);
                entities.Add(building);
            }
        }