Ejemplo n.º 1
0
    // this is called when the player data is created
    public void Initialize(GD_Encounter encounter)
    {
        // vessel is random out of the given choices
        int numVessels = 0;

        if (encounter.m_vesselIdA != 0)
        {
            numVessels++;
        }

        if (encounter.m_vesselIdB != 0)
        {
            numVessels++;
        }

        if (encounter.m_vesselIdC != 0)
        {
            numVessels++;
        }

        var possibleVessels = new int[numVessels];

        var possibleVesselIndex = 0;

        if (encounter.m_vesselIdA != 0)
        {
            possibleVessels[possibleVesselIndex++] = encounter.m_vesselIdA;
        }

        if (encounter.m_vesselIdB != 0)
        {
            possibleVessels[possibleVesselIndex++] = encounter.m_vesselIdB;
        }

        if (encounter.m_vesselIdC != 0)
        {
            possibleVessels[possibleVesselIndex++] = encounter.m_vesselIdC;
        }

        // pick a vessel
        var randomIndex = UnityEngine.Random.Range(0, possibleVessels.Length);

        m_vesselId = possibleVessels[randomIndex];

        // reset some important stuff
        m_coordinates         = Vector3.zero;
        m_targetCoordinates   = Vector3.zero;
        m_currentDirection    = Vector3.forward;
        m_lastDirection       = Vector3.forward;
        m_currentBankingAngle = 0.0f;
        m_timeSinceLastTargetCoordinateChange = 0.0f;
        m_isDead           = false;
        m_addedToEncounter = false;
    }
Ejemplo n.º 2
0
    public void Reset(int encounterId)
    {
        // get access to the game data
        var gameData = DataController.m_instance.m_gameData;

        // remember the encounter id
        m_encounterId = encounterId;

        // get access to the encounter
        m_encounter = gameData.m_encounterList[encounterId];

        // set the location (translated)
        switch (m_encounter.m_location)
        {
        case 0: m_location = PD_General.Location.Hyperspace; break;

        case 1: m_location = PD_General.Location.StarSystem; break;

        case 2: m_location = PD_General.Location.InOrbit; break;
        }

        if (m_location != PD_General.Location.Hyperspace)
        {
            foreach (var star in gameData.m_starList)
            {
                if (star.m_xCoordinate == m_encounter.m_xCoordinate)
                {
                    if (star.m_yCoordinate == m_encounter.m_yCoordinate)
                    {
                        m_starId = star.m_id;
                        break;
                    }
                }
            }
        }

        // set the home position
        if (m_location == PD_General.Location.Hyperspace)
        {
            m_homeCoordinates = Tools.GameToWorldCoordinates(new Vector3(m_encounter.m_xCoordinate, 0.0f, m_encounter.m_yCoordinate));
        }
        else if (m_location == PD_General.Location.StarSystem)
        {
            var randomPosition = UnityEngine.Random.insideUnitCircle * (8192.0f - 512.0f);

            m_homeCoordinates = new Vector3(randomPosition.x, 0.0f, randomPosition.y);
        }
        else
        {
            m_homeCoordinates = Vector3.zero;
        }

        // set the current coordinates to be at home
        m_currentCoordinates = m_homeCoordinates;

        // allocate and initialize each of the alien ships in the encounter
        m_alienShipList = new PD_AlienShip[m_encounter.m_maxNumShips];

        for (var i = 0; i < m_alienShipList.Length; i++)
        {
            var alienShip = new PD_AlienShip();

            alienShip.Initialize(m_encounter);

            m_alienShipList[i] = alienShip;
        }

        // allocate the shown comm list
        m_shownCommList = new List <int>();

        // initialize the encounter distance
        m_currentDistance = float.MaxValue;
    }