internal UnityMatchManager()
        {
            matchManager = new MatchManager();

            unityEntityManager2D = new UnityEntityManager(this, RepresentationMode.Mode2D);
            unityEntityManager3D = new UnityEntityManager(this, RepresentationMode.Mode3D);

            unityCameraManager2D = new UnityCameraManager(RepresentationMode.Mode2D);
            unityCameraManager3D = new UnityCameraManager(RepresentationMode.Mode3D);

            userInterfaceManager = new UserInterfaceManager(GameObject.Find("Canvas"));

            var hudActivity = new HudActivity(this, userInterfaceManager.canvasObject.transform.Find("HUD").gameObject);

            userInterfaceManager.RegisterActivity(hudActivity);
            userInterfaceManager.ShowActivity(hudActivity.name);

            UpdateRepresentationMode();

            foreach (var poolItem in ExamplePoolConfig.Pools)
            {
                matchManager.entityManager.InitPool(poolItem.name, poolItem.count);

                unityEntityManager2D.InitPool(poolItem.name, poolItem.count);
                unityEntityManager3D.InitPool(poolItem.name, poolItem.count);
            }
        }
        internal UnityEntity(UnityEntityManager unityEntityManager, string name, int componentCount)
        {
            this.unityEntityManager = unityEntityManager;

            this.name = name;

            var prefab = Resources.Load <GameObject>("Entities/" + unityEntityManager.representationMode + "/" + name);

            if (prefab == null)
            {
                throw new Exception("Could not load prefab by name: " + name + " and representation: " + unityEntityManager.representationMode);
            }

            gameObject      = Object.Instantiate(prefab);
            gameObject.name = name + " " + unityEntityManager.representationMode;

            gameObject.SetActive(false);

            unityComponents = new UnityComponent[componentCount];
        }
Beispiel #3
0
        //TODO: Can replaced to visual component editor

        public static UnityEntity CreateNewEntityInstance(UnityEntityManager unityEntityManager, string name)
        {
            var unityEntity = new UnityEntity(unityEntityManager, name, 1);

            if (name == "Laser")
            {
                unityEntity.unityComponents[0] = new UnityLaserController(unityEntity);
            }
            else //general logic for other entities (example)
            {
                unityEntity.unityComponents[0] = new UnityTransform(unityEntity, name == "Bullet");
            }

            if (unityEntity == null)
            {
                throw new Exception("Could not create unity entity by name: " + name);
            }

            return(unityEntity);
        }