示例#1
0
        private void OnEnable()
        {
            ecsWorld     = new EcsWorld();
            systems      = new EcsSystems(ecsWorld);
            fixedSystems = new EcsSystems(ecsWorld);
            gameState    = new GameState();
            unitsPool    = gameObject.GetComponent <UnitsPool>();
            unitsPool.Prewarm(1000, configuration.unitView);

#if UNITY_EDITOR
            Leopotam.Ecs.UnityIntegration.EcsWorldObserver.Create(ecsWorld);
            Leopotam.Ecs.UnityIntegration.EcsSystemsObserver.Create(systems);
#endif

            systems
            .Add(new UnitsInitSystem())
            .Add(new ClickMoveSystem())
            .Add(new UnitSelectionSystem())
            .Add(new DebugInputsSystem())
            .Add(new DynamicNavSystem())
            .Inject(gameState)
            .Inject(configuration)
            .Inject(unitsPool)
            .Init();

            fixedSystems
            .Add(new SpawnCommandSystem())
            .Add(new MoveCommandSystem())
            .Inject(gameState)
            .Inject(configuration)
            .Inject(unitsPool)
            .Init();
        }
示例#2
0
    private void Awake()
    {
        instance = this;

        // 풀을 생성한다.
        var goMinionPool = new GameObject();

        goMinionPool.name = "Minion Pool";
        goMinionPool.transform.SetParent(this.transform);

        minionPool = goMinionPool.transform;

        // 미니언을 만들어 놓는다.
        CreateMinion();

        // 휴지통
        StartCoroutine(EmptyDeathUnitList());
    }
示例#3
0
    public void ActivateUnitFromPool(int player, int posx, int posy, UnitsPool kind)
    {
        //unitParent = p1UnitsContainer;
        if (player == 2)
        {
            //unitParent = p2UnitsContainer;
        }
        switch (kind)
        {
        case UnitsPool.Miner:
            if (player == 1)
            {
                unitPool = p1MinersPool;
            }
            else
            {
                unitPool = p2MinersPool;
            }
            break;

        case UnitsPool.Swordsman:
            if (player == 1)
            {
                unitPool = p1SwordsmanPool;
            }
            else
            {
                unitPool = p2SwordsmanPool;
            }
            break;

        case UnitsPool.Knight:
            if (player == 1)
            {
                unitPool = p1KnightPool;
            }
            else
            {
                unitPool = p2KnightPool;
            }
            break;
        }

        if (unitPool.childCount > 0)
        {
            unitToActivate = unitPool.GetChild(0);
        }
        else
        {
            // "You cant create more units"

            Debug.Log("Cant create this unit");

            return;
        }

        if (unitToActivate != null)
        {
            // Create Unit

            unitToActivate.GetComponent <Unit>().ActivateUnit(posx, posy);

            //unitTocreate.transform.parent = unitParent;
            //unitTocreate.gameObject.SetActive(true);
        }
    }