Ejemplo n.º 1
0
    private void UpdateShipPositions()
    {
        var lowerPosition = Camera.main.ScreenToWorldPoint(new Vector3(0f, 200f, -Camera.main.transform.position.z));

        lowerPosition.x = 0;
        lowerPosition.z = 0;
        var upperPosition = Camera.main.ScreenToWorldPoint(new Vector3(0f, Camera.main.pixelHeight, -Camera.main.transform.position.z));

        upperPosition.x = 0;
        upperPosition.z = 0;

        var blueforShips = BlueforShips.ToArray();

        for (var index = 0; index < blueforShips.Length; index++)
        {
            blueforShips[index].transform.position = new Vector3(-8f, 0f, 0f) + Vector3.Lerp(
                lowerPosition,
                upperPosition,
                (index + 1f) / (blueforShips.Length + 1));
        }

        var redforShips = RedforShips.ToArray();

        for (var index = 0; index < redforShips.Length; index++)
        {
            redforShips[index].transform.position = new Vector3(8f, 0f, 0f) + Vector3.Lerp(
                lowerPosition,
                upperPosition,
                (index + 1f) / (redforShips.Length + 1));
        }
    }
Ejemplo n.º 2
0
    private void Start()
    {
        _ships.Clear();
        _ships.AddRange(FindObjectsOfType <Ship>());
        foreach (var ship in _ships)
        {
            ship.transform.SetParent(ShipsParent);
        }
        var playerShips = BlueforShips.ToArray();

        _playerShipControls.Clear();
        for (var index = 0; index < playerShips.Length; index++)
        {
            _playerShipControls.Add(CreatePlayerShipControl(playerShips[index], index));
        }
        UpdateShipPositions();
        PlayerShipControlParent.gameObject.SetActive(false);
        _dialog  = FindObjectOfType <Dialog>();
        _ai      = new IdiotAI(this);
        _mission = FindObjectOfType <Mission>();
        _state   = State.Running;

        StartCoroutine(StartMission());
    }