Inheritance: MonoBehaviour
示例#1
0
    private void OnSceneLoaded(Scene scene)
    {
        Debug.Log("GameLogic got scene");

        SimulationScene = scene;

        var rootGameObjects = SimulationScene.GetRootGameObjects();
        var rootGameObject  = rootGameObjects[0];

        // Disable GameLoopManager in the physics scene.
        rootGameObject.GetComponentInChildren <GameLoopManager>().gameObject.SetActive(false);

        TargetHole = rootGameObject.GetComponentsInChildren <Transform>()
                     .First(child => child.gameObject.name == "TargetHole").gameObject;

        // Disable cameras in the physics scene.
        foreach (var camera in rootGameObject.GetComponentsInChildren <Camera>())
        {
            camera.gameObject.SetActive(false);
        }

        // Disable light in the physics scene.
        foreach (var light in rootGameObject.GetComponentsInChildren <Light>())
        {
            light.gameObject.SetActive(false);
        }

        // Make all objects in the physics scene invisible.
        foreach (var renderer in rootGameObject.GetComponentsInChildren <Renderer>())
        {
            renderer.enabled = false;
        }

        // Find player balls.
        PlayerBalls = rootGameObject.GetComponentsInChildren <PlayerBall>();
        SimulationScene.GetPhysicsScene().Simulate(0.01f); // zero step for colliders

        if (PlayerBalls.Length != NumberOfPlayers)
        {
            throw new ArgumentException($"Inconsistent number of players: {PlayerBalls.Length} vs {NumberOfPlayers}");
        }

        // Initialize AIs.
        for (int i = 0; i < NumberOfPlayers; i++)
        {
            switch (PlayerTypes[i])
            {
            case PlayerType.Human:
                AIs[i] = null;
                Debug.Log(i + " is HUMAN");
                break;

            case PlayerType.DummyAI:
                AIs[i] = new DummyAI(this, i);
                Debug.Log(i + " is DUMMYAI");
                break;

            case PlayerType.EvilAI:
                AIs[i] = new EvilAI(this, i);
                Debug.Log(i + " is EVILAI");
                break;

            default:
                throw new ArgumentException($"Unknown player type: {PlayerTypes[i]}");
            }
        }

        NextMove();
    }
示例#2
0
 public void Init()
 {
     ai     = new DummyAI();
     client = new DummyClient();
 }
示例#3
0
 public void Init()
 {
     ai = new DummyAI();
       client = new DummyClient();
 }
 public void Init()
 {
     m_ai = new DummyAI();
       m_client = new DummyClient();
 }