コード例 #1
0
    protected override void Execute(List <GameEntity> entities)
    {
        foreach (var entity in entities)
        {
            GameEntity actionOwner = gameContext.GetEntityWithId(entity.parentLink.parentId);
            if (actionOwner != null)
            {
                GameEntity newWorker = null;
                switch (entity.unitType.type)
                {
                case UnitType.WORKER:
                    newWorker = UnitFactory.CreateWorker(gameContext);
                    break;

                case UnitType.WARRIOR:
                    newWorker = UnitFactory.CreateWarrior(gameContext);
                    break;
                }

                newWorker.AddOwner(actionOwner.owner.id);
                newWorker.AddPosition(actionOwner.position.position);
                newWorker.AddNavigationTarget(actionOwner.position.position);
            }
        }
    }
コード例 #2
0
    protected override void Execute(List <InputEntity> entities)
    {
        if (pointerPosition.GetEntities().Length > 0)
        {
            Vector3    pos      = pointerPosition.GetEntities().Last().inputPointerPosition.position;
            Ray        pointRay = Camera.main.ScreenPointToRay(pos);
            RaycastHit hit;
            if (Physics.Raycast(pointRay, out hit, float.PositiveInfinity, LayerMask.GetMask("Terrain")))
            {
                GameEntity newWarrior = UnitFactory.CreateWarrior(gameContext);
                newWarrior.AddOwner(1);

                newWarrior.AddPosition(hit.point);
                newWarrior.AddNavigationTarget(hit.point);
            }
        }
    }