示例#1
0
    void Start()
    {
        Statistics.GetInst().LoadStatistics();
        ePlayerShips selectedShip = ePlayerShips.Default;

        if (!RuntimeContext.GetInst().nesActPlayer.InitPlayerShip(selectedShip) || !LoadAndShowShip())
        {
            // WE FAILED TO INIT SHIP (!!)
            Debug.LogError("SHIP SELECTION >> FAILED to init or load ship...");
        }

#if UNITY_ANDROID
        ResetAccelerometerAxes();
#endif

#if SHIP_SELECT_ROTATE_PLAYER
        // get actual player's angles
        x = refPlayerInstance.transform.eulerAngles.y;
        y = refPlayerInstance.transform.eulerAngles.x;
#else
        // get actual camera angles
        x = refMainCamera.transform.eulerAngles.y;
        y = refMainCamera.transform.eulerAngles.x;
#endif

        MoveAndRotateCam(0.0f, 0.0f, 0.0f);
    }
示例#2
0
    void OnGUI()
    {
        if ((Screen.width != screenWidth) || (Screen.height != screenHeight))
        {
            CalcButtonRects();
        }

        ePlayerShips selectedShip = RuntimeContext.GetInst().nesActPlayer.actShip;

        if (selectedShip > (ePlayerShips.NO_SHIP + 1))
        {
            if (GUI.Button(realButtonPos[0], "<<"))
            {
                if (refPlayerInstance != null)
                {
                    Destroy(refPlayerInstance);

                    refPlayerInstance   = null;
                    refPlayerController = null;
                    refTargetTransform  = null;
                }

                // select previous ship from ship's list
                selectedShip -= 1;
                // init ship systems
                if (!RuntimeContext.GetInst().nesActPlayer.InitPlayerShip(selectedShip) || !LoadAndShowShip())
                {
                    // WE FAILED TO INIT SHIP (!!)
                    Debug.LogError("SHIP SELECTION >> FAILED to init or load ship...");
                }
            }
        }
        if (selectedShip < (ePlayerShips.END_PLAYER_SHIPS - 1))
        {
            if (GUI.Button(realButtonPos[1], ">>"))
            {
                if (refPlayerInstance != null)
                {
                    Destroy(refPlayerInstance);

                    refPlayerInstance   = null;
                    refPlayerController = null;
                    refTargetTransform  = null;
                }

                // select previous ship from ship's list
                selectedShip += 1;
                // init ship systems
                if (!RuntimeContext.GetInst().nesActPlayer.InitPlayerShip(selectedShip) || !LoadAndShowShip())
                {
                    // WE FAILED TO INIT SHIP (!!)
                    Debug.LogError("SHIP SELECTION >> FAILED to init or load ship...");
                }
            }
        }
    }
示例#3
0
    /**
     * @param select
     */
    bool LoadAndShowShip()
    {
        GameObject   tmpShip      = null;
        ePlayerShips selectedShip = RuntimeContext.GetInst().nesActPlayer.actShip;

        switch (selectedShip)
        {
        case ePlayerShips.AK5:
            tmpShip = refPlayerShipAK5;
            break;

        default:
            tmpShip = refPlayerShipDefault;
            break;
        }

        refPlayerInstance = Instantiate(tmpShip, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity) as GameObject;
        if (refPlayerInstance != null)
        {
            refPlayerController = refPlayerInstance.GetComponent <PlayerController>();
            if (refPlayerController == null)
            {
                Debug.LogError("SHIP SELECTION >> FAILED to obtain reference to PlayerController Class");
                return(false);
            }

            bool playerOK = refPlayerController.InitShip(
                RuntimeContext.GetInst().nesActPlayer.actLifes,
                RuntimeContext.GetInst().nesActPlayer.actHealth,
                0.0f,                                        //RuntimeContext.GetInst ().nesActPlayer.actShield,
                RuntimeContext.GetInst().nesActPlayer.actEnergy,
                RuntimeContext.GetInst().nesActPlayer.actEnergyType,
                RuntimeContext.GetInst().nesActPlayer.topWeaponType,
                RuntimeContext.GetInst().nesActPlayer.topAmmoType);
            if (playerOK)
            {
                refPlayerController.gameObject.SetActive(true);

                // just show, do not move the ship
                refPlayerController.nesEngiSys.Init(0.0f, 0.0f, false);

                // disable engines particle system --> it does not look good in this mode
                GameObject [] engines = GameObject.FindGameObjectsWithTag("Engine");
                for (int i = 0; i < engines.Length; i++)
                {
                    engines[i].SetActive(false);
                }

                if (Statistics.GetInst().nesTotScore.totalScore >= RuntimeContext.GetInst().nesActPlayer.scoreToUnlock)
                {
                    refTextUnlock.text = "The ship is UNLOCKED";
                }
                else
                {
                    refTextUnlock.text = "Score to unlock: " + RuntimeContext.GetInst().nesActPlayer.scoreToUnlock;
                }
                refTextLifes.text   = "Max Lifes: " + RuntimeContext.GetInst().nesActPlayer.actLifes;
                refTextHealth.text  = "Max Health: " + RuntimeContext.GetInst().nesActPlayer.topHealth;
                refTextShield.text  = "Max Shield: " + RuntimeContext.GetInst().nesActPlayer.topShield;
                refTextAmmo.text    = "Top Ammo: " + RuntimeContext.GetInst().nesActPlayer.topAmmoType;
                refTextWeapons.text = "Top Weapons: " + RuntimeContext.GetInst().nesActPlayer.topWeaponType;
            }
            else
            {
                refTextUnlock.text  = "";
                refTextLifes.text   = "";
                refTextHealth.text  = "";
                refTextShield.text  = "";
                refTextAmmo.text    = "";
                refTextWeapons.text = "";

                Debug.LogError("SHIP SELECTION >> FAILED to init player");
                return(false);
            }
        }
        else
        {
            Debug.LogError("SHIP SELECTION >> FAILED to instantiate player GameObject");
            return(false);
        }

        // get position of target object
        refTargetTransform = refPlayerInstance.transform;

        return(true);
    }