예제 #1
0
        // Begin a new game.
        public static void NewGame()
        {
            // Access the ECS entity manager
            var entityManager = World.Active.GetOrCreateManager <EntityManager>();

            // Create an entity based on the player archetype. It will get default-constructed
            // defaults for all the component types we listed.
            //Entity player = entityManager.CreateEntity(PlayerArchetype);
            var settingsGO = GameObject.Find("Settings");

            Settings = settingsGO?.GetComponent <TwoStickSettings>();
            if (!Settings)
            {
                Debug.Log("Settings f****d up in NewGame");
            }
            Entity player = ZenEntityFactory.CreateLinkedEntity(Settings.PlayerPrefab, PlayerArchetype);

            // We can tweak a few components to make more sense like this.
            entityManager.SetComponentData(player, new Position2D {
                Value = new float2(0.0f, 0.0f)
            });
            entityManager.SetComponentData(player, new Heading2D  {
                Value = new float2(0.0f, 1.0f)
            });
            entityManager.SetComponentData(player, new Health {
                Value = Settings.playerInitialHealth
            });

            entityManager.AddSharedComponentData(player, PlayerPrefab);

            // Finally we add a shared component which dictates the rendered look
            //entityManager.AddSharedComponentData(player, PlayerLook);
        }
예제 #2
0
        public static void InitializeWithScene()
        {
            var settingsGO = GameObject.Find("Settings");

            if (settingsGO == null)
            {
                SceneManager.sceneLoaded += OnSceneLoaded;
                return;
            }
            Settings = settingsGO?.GetComponent <TwoStickSettings>();
            if (!Settings)
            {
                return;
            }

            PlayerLook     = GetLookFromPrototype("PlayerRenderPrototype");
            PlayerShotLook = GetLookFromPrototype("PlayerShotRenderPrototype");
            EnemyShotLook  = GetLookFromPrototype("EnemyShotRenderPrototype");
            EnemyLook      = GetLookFromPrototype("EnemyRenderPrototype");

            EnemySpawnSystem.SetupComponentData(World.Active.GetOrCreateManager <EntityManager>());

            World.Active.GetOrCreateManager <UpdatePlayerHUD>().SetupGameObjects();

            var sceneSwitcher = GameObject.Find("SceneSwitcher");

            if (sceneSwitcher != null)
            {
                NewGame();
            }
        }
예제 #3
0
        public static void InitializeWithScene()
        {
            var settingsGO = GameObject.Find("Settings");

            Settings = settingsGO?.GetComponent <TwoStickSettings>();
            if (!Settings)
            {
                return;
            }

            //PlayerLook = GetLookFromPrototype("PlayerRenderPrototype");
            PlayerShotLook = GetLookFromPrototype("PlayerShotRenderPrototype");
            EnemyShotLook  = GetLookFromPrototype("EnemyShotRenderPrototype");
            //EnemyLook = GetLookFromPrototype("EnemyRenderPrototype");

            var prefab = GetPrefab("Prefabs/PlayerPrefab");

            //PlayerPrefab = GetPrefab("Prefabs/PlayerPrefab");

            EnemySpawnSystem.SetupComponentData(World.Active.GetOrCreateManager <EntityManager>());

            World.Active.GetOrCreateManager <UpdatePlayerHUD>().SetupGameObjects();
        }