Beispiel #1
0
    private void SetupPlayers(GameContext game, Presets preset, HexGridBehaviour grid)
    {
        PlayerListData pld = GameObject.FindObjectOfType <PlayerListData>();

        if (pld != null)
        {
            IEnumerator <Vector3> basePos = CoordinatesForBases(grid);
            foreach (var player in pld._model)
            {
                GameEntity pEntity = game.CreateEntity();
                pEntity.AddTeam(player.Color);
                pEntity.isLocalPlayer = (player.Type == PlayerTypeEnum.Human);
                pEntity.isAIPlayer    = (player.Type == PlayerTypeEnum.AI);

                basePos.MoveNext();
                GameEntity       baseEntity = preset.CreateBlueprint(Presets.EntitasPresetEnum.BASE);
                HexCellBehaviour home       = grid.GetCell(basePos.Current);
                baseEntity.ReplaceLocation(home, home.GetComponent <EntitasLink>().id);
                baseEntity.ReplaceTeam(player.Color);
                baseEntity.ReplaceStartPosition(home.transform.position.x, home.transform.position.y, home.transform.position.z);
            }
        }
        else
        {
            Debug.Log("No player setup found; I'm assuming this scene was started in Unity Editor for debugging purposes");

            GameEntity pEntity = game.CreateEntity();
            pEntity.AddTeam(0);
            pEntity.isLocalPlayer = true;
            pEntity.isAIPlayer    = false;
        }
    }
Beispiel #2
0
    private GameEntity CreateCommon(EntitasInit unityObject)
    {
        GameEntity ge = _game.CreateEntity();

        ge.AddGameObject(unityObject.gameObject);

        Vector3    pos = unityObject.transform.position;
        Quaternion rot = unityObject.transform.rotation;

        ge.AddWorldCoordinates(pos.x, pos.y, pos.z, rot.x, rot.y, rot.z, rot.w);

        HexCellBehaviour cell = _grid.GetCell(_grid.axial_to_cube(_grid.pixel_to_axial(unityObject.transform.position)));

        if (cell != null)
        {
            int id = cell.GetComponent <EntitasLink>().id;
            ge.AddLocation(cell, id);
        }

        HexSelectable selectable = unityObject.GetComponent <HexSelectable>();

        if (selectable != null)
        {
            ge.isSelectable = true;
        }

        TeamColor team = unityObject.GetComponent <TeamColor>();

        if (team != null)
        {
            ge.AddTeam(team.teamNr);
        }

        //now that the entity has been created with a unique ID,
        //put this ID on the unity GameObject for easy reference:
        EntitasLink el = unityObject.gameObject.AddComponent <EntitasLink>();

        el.id = ge.iD.value;

        return(ge);
    }