Beispiel #1
0
    public override void OnFullyCreated()
    {
        BossReadyZone readyPrefab = DungeonRoomObjectDict.Instance.BossReadyZone;
        Vector2       mid         = Border.position + (Border.size * 0.5f);

        for (int i = 0; i < doors.Count; i++)
        {
            doors[i].IsLocked = true;
            BoxCollider2D coll = doors[i].GetComponent <BoxCollider2D>();

            Vector2 pos    = doors[i].transform.position;
            Vector2 dir    = pos - mid;
            Vector2 offset = doors[i].IsLeftRight ?
                             (dir.x > 0 ? new Vector2(1, 0) : new Vector2(-1, 0)) // is left/right. Is it to the right or to the left?
                : (dir.y > 0 ? new Vector2(0, 1) : new Vector2(0, -1));           // is up/down. Is it to the up or the down?

            Rect          rect = new Rect(pos + coll.offset + offset, coll.size * doors[i].transform.lossyScale);
            BossReadyZone brz  = Instantiate(readyPrefab, transform);
            brz.Set(rect, doors[i]);
        }
    }
Beispiel #2
0
    public void OnAllPlayersReadyToEnter(BossReadyZone bossReadyZone)
    {
        CurrentState = State.InProgress;

        GameObject[] objs = SpawnBoss();
        CloseDoors();

        PlayersStartPos = (bossReadyZone.OnDoor.transform.position - bossReadyZone.transform.position) * 2 + bossReadyZone.transform.position;

        BossSpawnMessage bossSpawnMessage = new BossSpawnMessage {
            bossGameObjects = objs,
            id            = id,
            animationType = bossObjects[0].AnimationType
        };

        SpawnedEnemies = new Enemy[objs.Length];
        for (int i = 0; i < objs.Length; i++)
        {
            SpawnedEnemies[i] = objs[i].GetComponent <Enemy>();
        }

        NetworkServer.SendToAll(bossSpawnMessage);

        // Make all players not being able to move.
        List <Player> players = PlayersDict.Instance.Players;

        for (int i = 0; i < players.Count; i++)
        {
            players[i].RpcChangeCanMove(false);
        }

        // Start the boss animations.
        enterAnimation          = BossEnterAnimation.AddAnimationType(gameObject, bossObjects[0].AnimationType);
        enterAnimationCoroutine = new ExtendedCoroutine(this, enterAnimation.PlayAnimation(objs[0], this),
                                                        StartCheckingForAllPlayersWatchedEnterAnimation, true);

        GameManager.OnRoomEventStarted();
    }