TouhouLS/Assets/RealCode/GameBoardInstance.cs

50 lines
1.1 KiB
C#
Raw Normal View History

2020-08-22 05:29:00 +00:00
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class GameBoardInstance : MonoBehaviour {
public static GameBoardInstance instance { get; private set; }
public GameBoard player1, player2;
public GameObject tilePrefab;
public Sprite[] regular;
public Sprite[] lit;
public Sprite[] activators;
[Header("AI difficulty, 0(easy)-3(hardest)")]
public int AIDifficulty = 1;
2020-08-22 05:29:00 +00:00
private void Awake() {
instance = this;
}
public void SetupGame(){
2020-08-22 07:34:54 +00:00
2020-08-22 05:29:00 +00:00
if (NetworkManager.inRoom){
var players = NetworkManager.net.CurrentRoom.Players.Values.OrderBy(p => p.ID);
var p1 = players.ElementAt(0);
var p2 = players.ElementAt(1);
player1.authorityID = p1.ID;
player2.authorityID = p2.ID;
player1.Setup();
player2.Setup();
} else {
player1.authorityID = -1;
player2.authorityID = -1;
2020-08-22 05:29:00 +00:00
player1.Setup();
player2.Setup();
player2.StartAI(new[] { 0.5f, 0.2f, 0.1f, 0f }[AIDifficulty]);
}
2020-08-22 05:29:00 +00:00
GameTransition.Instance.state = GameState.InGame;
}
}