Ejemplo n.º 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);
            }
        }
    }
Ejemplo n.º 2
0
    public void Initialize()
    {
        gameContext.ReplaceLocalPlayer(0);
        Ray        centerRay = Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
        RaycastHit hit;

        if (Physics.Raycast(centerRay, out hit))
        {
            for (int i = 0; i < 3; ++i)
            {
                GameEntity entity   = UnitFactory.CreateWorker(gameContext);
                Vector3    newPoint = hit.point + new Vector3(UnityEngine.Random.Range(-0.1f, 0.1f), 0, UnityEngine.Random.Range(-0.1f, 0.1f));
                entity.AddNavigationTarget(newPoint);
                entity.AddPosition(newPoint);
                entity.AddOwner(0);
            }
        }
    }