Beispiel #1
0
    public void Init(Elemental.Element element = Elemental.Element.NONE)
    {
        _instance = this;

        _rigidbody = GetComponent <Rigidbody>();

        SetupStateMachine();
        _cameraController = FindObjectOfType <GolfCameraController>();
        StopAllForces();
        ResetToPosition(InitialPosition);
        _stateMachine.ChangeState(_waitForInputState);
        _cameraController.SetInitialCamera();

        EventManager.Instance.StartListening(ShootEvent.EventName, PanFinished);

        _elementalAbsorber = transform.GetComponent <ElementalAbsorber>();
        if (element == Elemental.Element.NONE)
        {
            return;
        }

        if (element != Elemental.Element.ANY)
        {
            _elementalAbsorber.CurrentElement = element;
            return;
        }

        List <Elemental.Element> availableColors = new List <Elemental.Element>();

        availableColors.Add(Elemental.Element.EARTH);
        availableColors.Add(Elemental.Element.FIRE);
        availableColors.Add(Elemental.Element.WATER);

        _elementalAbsorber.CurrentElement = (Elemental.Element)UnityEngine.Random.Range(0, availableColors.Count);
    }
 void Start()
 {
     floor = GameObject.Instantiate(floorPrefab,new Vector3(-20, 0 ,-20),Quaternion.identity) as GameObject;
     if (layla == null) { layla = GameObject.Find("Layla");
     }
     liaison = layla.GetComponent<GameControlLiaison>();
     players = new Player[liaison.numberOfActivePlayers];
     if (players.Length > 1) {
         golfBalls = new GameObject[players.Length - 1];
         Debug.Log ("Number of balls: " + (players.Length - 1));
     } else {
         golfBalls = new GameObject[1];
         Debug.Log ("Only one player so only one ball");
     }
     for (int p = 0; p < players.Length; p++)
     {
         players[p] = liaison.players[p];
     }
     respawnPointPositions = new Vector3[respawnPoints.Length];
     for (int i = 0; i < respawnPoints.Length; i++)
     {
         respawnPointPositions[i] = respawnPoints[i].transform.position;
     }
     //players = liaison.players;
     Debug.Log("Wizard is setting " + players.Length +" players.");
     ResetExistingPlayers();
     SetPlayers();
     SpawnBallAndHole();
     camScript = Camera.main.GetComponent<GolfCameraController>();
     finished = false;
     victoryDuration = 3;
     UpdateStatCards();
     inGame.GetComponent<InGamePlayerBoard>().SetPlayers = players;
 }