Exemplo n.º 1
0
    public void BuildGame(LevelSpecification level)
    {
        // Build board
        Debug.Log(">>> Building board from level " + level.ToJSON());
        ResetBoard();
        board = Instantiate(BoardPrefab, transform).GetComponent <PlatformBoardBehaviour>();
        board.Build(level.PlatformRequirements[0]);

        // Locate board elements
        Debug.Log(">>> Board built, locating elements");

        arpb2 = board.LocateElement(MainCharacterPrefab, level.Origin.Coordinate).GetComponent <MainCharacterBehaviour>();
        arpb2.ResetPoints();
        arpb2.Orientation = level.Origin.Orientation;

        if (level.Collectibles != null)
        {
            foreach (Collectible collectibe in level.Collectibles)
            {
                board.LocateElement(EnergyCellPrefab, collectibe.Coordinate);
            }
        }

        List <GameObject> pads = new List <GameObject>();

        if (level.Pads != null)
        {
            foreach (Pad pad in level.Pads)
            {
                GameObject teleportPad = board.LocateElement(TeleportPadPrefab, pad.Coordinate);
                pads.Add(teleportPad);
            }

            pads[0].GetComponent <CustomTeleporter>().destinationPad[0] = pads[1].transform;
            pads[1].GetComponent <CustomTeleporter>().destinationPad[0] = pads[0].transform;
        }

        board.LocateElement(FlagPrefab, level.Destination.Coordinate);

        GetComponent <GameControllerBehaviour>().Board = board;
        GetComponent <GameControllerBehaviour>().ARPB2 = arpb2;

        Debug.Log(">>> All elements located");
    }
Exemplo n.º 2
0
 void Start()
 {
     player = FindObjectOfType <MainCharacterBehaviour>();
     player.onWoodChopped += OnWoodChopped;
     countDownToHide       = achievementStayDuration;
 }
Exemplo n.º 3
0
 private void Awake()
 {
     character = FindObjectOfType <MainCharacterBehaviour>();
     character.onWoodChopped += OnWoodChopped;
 }