示例#1
0
文件: CGame.cs 项目: dvochin/Scripts
    public void Start()
    {
        //    StartCoroutine(Coroutine_StartGame());			// Handled by a coroutine so that our 'OnGui' can run to update the 'Please wait' dialog
        //}
        //public IEnumerator Coroutine_StartGame() {		//####OBS: IEnumerator?? //###NOTE: Game is started by iGUICode_Root once it has completely initialized (so as to present the 'Please Wait...' dialog

        Debug.Log("=== CGame.StartGame() ===");
        INSTANCE = this;
        _nTimeAtStart = Time.time;

        //GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CSoftBody));     //###NOW###
        ////GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CSoftBodyBase));     //###NOW###
        ////GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CB));     //###NOW###
        ////GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CFuckOff));
        ////GameObject oGO_HACK = new GameObject("oGO_HACK", typeof(CJointDriver));
        //return;

        _oFlexSolver = FindObjectOfType<uFlex.FlexSolver>();        //###F
        GameObject oSceneGO = GameObject.Find("SCENE/SceneColliders");
        //if (oSceneGO != null)
        //    s_aColliders_Scene = oSceneGO.GetComponentsInChildren<CCollider_OBS>();

        _bRunningInEditor = true;       //###HACK ####REVA Application.isEditor
        _DemoVersion = (_bRunningInEditor == false);		//###CHECK? If dev has Unity code they are non-demo

        _oCursor = CCursor.Cursor_Create();             //###DESIGN!!!!!: REVISIT!	###CLEANUP!!!!!
        Cursor.visible = Application.isEditor;      // _bRunningInEditor;

        //=== Set rapid-access members to text widgets so we can rapidly update them ===
        _oTextUL = GameObject.Find("/UI/CanvasScreen/UL/Text-UL").GetComponent<Text>();
        _oTextUC = GameObject.Find("/UI/CanvasScreen/UC/Text-UC").GetComponent<Text>();
        _oTextUR = GameObject.Find("/UI/CanvasScreen/UR/Text-UR").GetComponent<Text>();

        //=== Create user-adjustable top-level game options ===
        _oObj = new CObject(this, 0, typeof(EGamePlay), "Erotic9");		//###TEMP!!! Main game name in this low-importance GUI???
        _oObj.PropGroupBegin("", "", true);		//###CLEANUP
        //_oObj.PropAdd(EGamePlay.Pleasure,			"Pleasure",		30,		-100,	100,	"Amount of pleasure experienced by game characters.  Influences 'Arousal' (NOTE: Temporary game mechanism)");	//###BUG with first setting
        //_oObj.PropAdd(EGamePlay.Arousal,			"Arousal",		0,		0,		100,	"Current state of arousal from game characters.  Currently influence penis size.  (NOTE: Temporary game mechanism)");
        //_oObj.PropAdd(EGamePlay.PoseRootPos,		"Pose Root Position",typeof(EPoseRootPos), 0,	"Base location of pose root.  (e.g. on bed, by bedside, etc)");
        //_oObj.PropAdd(EGamePlay.PenisSize,			"Penis Size",	0,		0,		100,	"", CProp.ReadOnly | CProp.Hide);
        //_oObj.PropAdd(EGamePlay.PenisErectionMax,	"Erection",		0,		0,		100,	"", CProp.ReadOnly | CProp.Hide);
        //_oObj.PropAdd(EGamePlay.FluidConfig,		"Fluid Configuration", 0, "Display the properties of the Erotic9 fluid simulator.  (Advanced)", CProp.AsButton);
        _oObj.FinishInitialization();
        _oHotSpot = CHotSpot.CreateHotspot(this, transform, "Game Options", false, new Vector3(0, 0.0f, 0.0f), 1.0f);

        //if (_GameModeAtStartup == EGameModes.None) {
        //    yield break;
        //}

        float nDelayForGuiCatchup = _bRunningInEditor ? 0.2f : 0.01f;		//###HACK? ###TUNE: Adjustable delay to give iGUI time to update 'Game is Loading' message, with some extra time inserted to make Unity editor appear more responsive during game awake time
        ///yield return new WaitForSeconds(nDelayForGuiCatchup);

        //=== Send async call to authentication so it is ready by the time game has initialized ===
        //		WWW oWWW = null;
        //		if (Application.genuine) {		//###CHECK: Has any value against piracy???
        //			if (Application.internetReachability != NetworkReachability.NotReachable) {		//###CHECK!!!
        //				//####BROKEN?! Why store it if we don't use it? string sMachineID = PlayerPrefs.GetString(G.C_PlayerPref_MachineID);
        //				string sMachineID = CGame.GetMachineID();		//###CHECK Can cause problems if switching adaptors frequently?
        //				oWWW = new WWW("http://www.erotic9.net/cgi-bin/CheckUser.py?Action=Authenticate&MachineID=" + sMachineID);
        //			} else {
        //				Debug.LogError("Warning: Could not authenticate because of Internet unreacheability.");
        //			}
        //		} else {
        //			Debug.LogError("Warning: Could not authenticate because of executable image corruption.");
        //		}

        //=== Try to load our dll to extract helpful error message if it fails, then release it ===
        //Debug.Log("INIT: Attempting to load ErosEngine.dll");         //###BROKEN!  WTF No longer works loading 64 bit dll??
        //int hLoadLibResult = LoadLibraryEx("ErosEngine.dll", 0, 2);
        //if (hLoadLibResult > 32)
        //	FreeLibrary(hLoadLibResult);			// Free our dll so Unity can load it its way.  Based on code sample at http://support.microsoft.com/kb/142814
        //else
        //	CUtility.ThrowException("ERROR: Failure to load ErosEngine.dll.  Error code = " + hLoadLibResult);		// App unusable.  Study return code to find out what is wrong.
        //Debug.Log("INIT: Succeeded in loading ErosEngine.dll");

        //####OBS? GameObject oGuiGO = GameObject.Find("iGUI");			//###TODO!!! Update game load status... ###IMPROVE: Async load so OnGUI gets called???  (Big hassle for that!)
        Debug.Log("0. Game Awake"); ///yield return new WaitForSeconds(nDelayForGuiCatchup);
        int n123 = ErosEngine.Utility_Test_Return123_HACK();			// Dummy call just to see if DLL will load with Unity
        if (n123 != 123)
            CUtility.ThrowException("ERROR: Failure to get 123 from ErosEngine.dll call to Utility_Test_Return123_HACK.");
        Debug.Log("INIT: Succeeded in loading ErosEngine.dll");

        //=== Initialize our gBlender direct-memory buffers ===
        Debug.Log("1. Shared Memory Creation.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        if (ErosEngine.gBL_Init(CGame.GetFolderPathRuntime()) == false)
            CUtility.ThrowException("ERROR: Could not start gBlender library!  Game unusable.");

        //=== Spawn Blender process ===
        Debug.Log("2. Background Server Start.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);	//###CHECK: Cannot wait long!!
        _hWnd_Unity = (IntPtr)GetActiveWindow();			// Just before we start Blender obtain the HWND of our Unity editor / player window.  We will need this to re-activate our window.  (Starting blender causes it to activate and would require user to alt-tab back to game!!)
        _oProcessBlender = CGame.LaunchProcessBlender("Erotic9.blend");
        if (_oProcessBlender == null)
            CUtility.ThrowException("ERROR: Could not start Blender!  Game unusable.");
        //_nWnd_Blender_HACK = (IntPtr)GetActiveWindow();

        //=== Start Blender (and our gBlender scripts).  Game cannot run without them ===
        Debug.Log("3. Client / Server Handshake.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        if (ErosEngine.gBL_HandshakeBlender() == false)
            CUtility.ThrowException("ERROR: Could not handshake with Blender!  Game unusable.");

        SetForegroundWindow(_hWnd_Unity);           // Set our editor / player back into focus (away from just-spawned Blender)

        //=== Set Blender global variables ===
        CGame.gBL_SendCmd("G", "CGlobals.SetFlexParticleSpacing(" + CGame.INSTANCE.particleSpacing.ToString() + ")");         //###TODO: Add others?

        //=== Start PhysX ===
          //      Debug.Log("4. PhysX3 Init.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        //ErosEngine.PhysX3_Create();						// *Must* occur before any call to physics library...  So make sure this object is listed with high priority in Unity's "Script Execution Order"

        //Debug.Log("5. PhysX2 Init.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        //ErosEngine.PhysX2_Create();						//###IMPROVE!!! Return argument ###NOTROBUST

        //Debug.Log("6. OpenCL Init.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        //		if (System.Environment.CommandLine.Contains("-DisableOpenCL") == false)	//###TODO More / better command line processing?		//###SOON ####BROKEN!!!!! OpenCL breaks cloth GPU!
        //			ErosEngine.MCube_Init();		//###IMPROVE: Log message to user!

        SetForegroundWindow(_hWnd_Unity);			//###WEAK: Can get rid of??

        //=== Start misc stuff ===
        Debug.Log("7. CGame globals.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);
        _oSceneMeshesGO = GameObject.Find("SceneMeshes");			// Remember our scene game object so we can hide/show

        _aGuiMessages = new string[(int)EGameGuiMsg.COUNT];
        _ShowFPS = _ShowSysInfo = _bRunningInEditor;

        //###IMPROVE: Disabled until we need to save CPU cycles...  Create upon user demand to record script!
        //_oScriptRecordUserActions = new CScriptRecord(GetPathScript("RecordedScript"), "Automatically-generated Erotic9 Scene Interation Script");

        _oPoseRoot = GameObject.Find("CPoseRoot").GetComponent<CPoseRoot>();
        _oPoseRoot.OnStart();

        //_oFluid = gameObject.AddComponent<CFluid>();
        //_oFluid.OnAwake();

        Application.targetFrameRate = _TargetFrameRate;			//###BUG!!! Why no effect????
        _DefaultJointSpringOld = _DefaultJointSpring;		//###OBS
        _DefaultJointDampingOld = _DefaultJointDamping;

        _oCamTarget = GameObject.Find("CCamTarget").GetComponent<CCamTarget>();		//###WEAK!!!
        _oCamTarget.OnStart();

        Debug.Log("8. Body Assembly.");  //###???  new WaitForSeconds(nDelayForGuiCatchup);		//###WEAK!!!

        //_oFluid.OnStart();								//###CHECK: Keep interleave

        SetGameModeBasicInteractions(true);

        //=== Find the static scene colliders in 'SceneColliders' node and initialize them ===
        //Debug.Log("CGame.StartGame() Registering Static Colliders: " + s_aColliders_Scene.Length);
          //  if (s_aColliders_Scene != null)
            //foreach (CCollider_OBS oColStatic in s_aColliders_Scene)		// Colliders that are marked as static registered themselves to us in their Awake() so we can start and destroy them
               // oColStatic.OnStart();

        //StartCoroutine(Coroutine_Update100ms());
        StartCoroutine(Coroutine_Update500ms());

        _GameIsRunning = true;
        enabled = true;
        Debug.Log("+++ GameIsRunning ++");

        Debug.Log("7. Scene settling time.");  //###???  new WaitForSeconds(2.0f);		//###DESIGN??  ###TUNE??
        ///_oGui.ShowSceneBlanker(false);
        ///_oGui.ShowPanelGameLoad(false);

        //=== Check result of user authentication ===
        /*
        if (oWWW != null) {
            yield return oWWW;
            string sResultAuth = oWWW.text;
            _DemoVersion = sResultAuth.Contains("Result=OK") == false;		//###IMPROVE: Create parse routine and return server errors
            Debug.Log("Auth Results = " + sResultAuth);
            if (_DemoVersion == false)
                Debug.Log("Starting game in non-demo mode.");
        }*/
        //_DemoVersion = false;
        //if (_DemoVersion)
        //	Debug.Log("Starting game in demo mode.");		//###TODO: Temp caption!

        ///		if (_bRunningInEditor == false)
        ///			CUtility.WndPopup_Create(EWndPopupType.LearnToPlay, null, "Online Help", 50, 50);	// Show the help dialog at start... ###BUG: Does not change the combo box at top!

        SetForegroundWindow(_hWnd_Unity);           //###WEAK: Can get rid of??

        //if (CGame.INSTANCE._GameMode == EGameModes.None)        //####TEMP
        //    return;

        //=== Create the body publicly-editable body definitions that can construct and reconstruct CBody instances ===
        //CGame.INSTANCE._nNumPenisInScene_BROKEN = 0;

        //###NOTE: For simplification in pose files we always have two bodies in the scene with man/shemale being body 0 and woman body 1
        //CreateBody(0);
        //      //CreateBody(1);
        _aBodyBases[0] = new CBodyBase(0, EBodySex.Woman);
        //###BROKEN _aBodyBases[0].SelectBody();

        TemporarilyDisablePhysicsCollision();

        ///SetPenisInVagina(false);		// We initialize the penis in v****a state to false so v****a track colliders don't kick in at scene init

        if (CGame.INSTANCE._GameMode == EGameModes.Play)
            ScenePose_Load("Standing", false);          // Load the default scene pose

        //###TODO ##NOW: Init GUI first!!
        //iGUISmartPrefab_WndPopup.WndPopup_Create(new CObject[] { oObj }, "Game Play", 0, 0);		//###TEMP

        //Time.timeScale = 0.05f;		//###REVA ###TEMP   Gives more time for cloth to settle... but fix it some other way (with far stronger params??)

        ChangeGameMode(_GameModeAtStartup);             // Set the initial game mode as statically requested

        Debug.LogFormat("Time at startup end: {0}", Time.time - _nTimeAtStart);
        //ScenePose_Load("Standing", false);          // Load the default scene pose
    }
示例#2
0
    void OnGUI()
    {
        GUI.skin.font = m_fStandard;

        // Title
        GUI.DrawTexture(m_rectTitle, m_TitleTexture);

        GUILayout.BeginArea(m_rectTitle);

        Rect rectNextEntry      = m_rectSpellEntry;
        Rect rectNextSpellTitle = m_rectSpellTitle;
        Rect rectNextSpellIcon  = m_rectSpellIcon;
        Rect rectNextSpellCost  = m_rectSpellCost;
        Rect rectNextSpellDesc  = m_rectSpellDesc;

        CCursor oCursor   = GameApp.GetInstance().GetCursor();
        Vector2 vMousePos = oCursor.GetScreenPosition();

        vMousePos.x -= m_rectTitle.x;
        vMousePos.y -= m_rectTitle.y;

        bool bHasSpell;
        //string sSpellDesc;
        uint uiCost;
        uint uiLevel;

        const int iColMax = 2;
        const int iRowMax = 4;

        for (int iCol = 0; iCol < iColMax; ++iCol)
        {
            for (int iRow = 0; iRow < iRowMax; ++iRow)
            {
                int iSpellIndex = (iCol * iRowMax) + iRow;
                // Check for spell ownership
                CSpellData.TSpellData tSpell = m_atSpellData[iSpellIndex];
                if (tSpell.eType == CSpell.EType.INVALID)
                {
                    Debug.Log(tSpell.eType.ToString());
                    // continue
                    // Note continue didnt work so I had to group it in this else block
                }
                else
                {
                    bHasSpell = m_oSpellBook.HasSpell(tSpell.eType);

                    if (bHasSpell)
                    {
                        uiLevel = m_oSpellBook.GetSpell(tSpell.eType).GetUpgradedLevel();
                        uiCost  = tSpell.uiUpgradeCost + uiLevel;
                    }
                    else
                    {
                        //sSpellDesc = "";
                        uiCost  = tSpell.uiBuyCost;
                        uiLevel = 0;
                    }

                    GUI.DrawTexture(rectNextEntry, m_SpellEntry);

                    // Show Desc here
                    GUI.Label(rectNextSpellDesc, "Lv: " + uiLevel + Environment.NewLine + tSpell.sDescription);



                    if (rectNextEntry.Contains(vMousePos))
                    {
                        if (oCursor.IsMouseDown())
                        {
                            GUI.DrawTexture(rectNextEntry, m_SpellEntry_Selected);
                        }
                        else
                        {
                            GUI.DrawTexture(rectNextEntry, m_SpellEntry_MouseOver);
                        }
                        if (Input.GetMouseButtonUp(0) && m_bFirstClick)
                        {
//							if(m_oSpellBook.HasSpell(tSpell.eType))
//							{
//								UpgradeSpell(tSpell.eType, uiCost);
//							}
//							else
//							{
//								//PurchaseSpell(tSpell.eType, uiCost);
//							}
//
//							 m_bFirstClick = false;
                        }

                        // Show Buy/Upgrade Desc here

                        if (bHasSpell)
                        {
                            GUI.Label(rectNextSpellDesc, "Lv: " + uiLevel + " -> " + (uiLevel + 1) + Environment.NewLine + m_oSpellBook.GetSpell(tSpell.eType).GetShopUpgradeDetails());
                        }
                        else
                        {
                            GUI.Label(rectNextSpellDesc, "Lv: " + uiLevel + " -> " + (uiLevel + 1) + Environment.NewLine + tSpell.sShopDetails);
                        }
                    }

                    GUI.DrawTexture(rectNextSpellTitle, tSpell.tNameTexture);

                    // Text Spell titles
                    GUI.skin.font = m_fXXLarge;
                    Rect rectLabel = rectNextSpellTitle;
                    rectLabel.y      -= 5;
                    rectLabel.height += 5;
                    GUI.Label(rectLabel, tSpell.sTitle);
                    GUI.skin.font = m_fStandard;

                    GUI.DrawTexture(rectNextSpellIcon, tSpell.tTexture);
                    GUI.DrawTexture(rectNextSpellIcon, m_tSpellFrame);


                    GUI.DrawTexture(rectNextSpellCost, m_tCrystalCost);
                    Rect rectSpellCost = rectNextSpellCost;
                    rectSpellCost.x += 35;
                    rectSpellCost.y += 6;

                    GUI.skin.font = m_fXLarge;
                    GUI.Label(rectSpellCost, uiCost.ToString());
                    GUI.skin.font = m_fStandard;


                    rectNextEntry.y      += 132;                // height offset
                    rectNextSpellTitle.y += 132;
                    rectNextSpellIcon.y  += 132;
                    rectNextSpellCost.y  += 132;
                    rectNextSpellDesc.y  += 132;
                }
            }

            rectNextEntry.x += 365;             // width offset
            rectNextEntry.y  = m_rectSpellEntry.y;

            rectNextSpellTitle.x += 365;             // width offset
            rectNextSpellTitle.y  = m_rectSpellTitle.y;

            rectNextSpellIcon.x += 365;             // width offset
            rectNextSpellIcon.y  = m_rectSpellIcon.y;

            rectNextSpellCost.x += 365;             // width offset
            rectNextSpellCost.y  = m_rectSpellCost.y;

            rectNextSpellDesc.x += 365;             // width offset
            rectNextSpellDesc.y  = m_rectSpellDesc.y;
        }

        GUI.skin.font = m_fXXLarge;
        GUI.Label(m_rectOwnedCrystals, m_oWarlockCurrency.Get().ToString());

        Rect rTime = m_rectOwnedCrystals;

        rTime.x -= 200;
        //GUI.Label(rTime, CSceneArena.m_kfShoppingDuration.ToString());
        GUI.Label(rTime, GameApp.GetInstance().GetSceneArena().GetShopTimer().ToString());

        GUILayout.EndArea();



        GUI.skin.font = m_fLarge;
    }
示例#3
0
        //* ────________________________________*
        //* methods ───────────────────────────────-*

        //* -----------------------------------------------------------------------*
        /// <summary>1フレーム分の描画処理を実行します。</summary>
        ///
        /// <param name="entity">この状態を適用されているオブジェクト。</param>
        /// <param name="privateMembers">
        /// オブジェクトと状態クラスのみがアクセス可能なフィールド。
        /// </param>
        /// <param name="gameTime">前フレームが開始してからの経過時間。</param>
        public override void draw(CEntity entity, CCursor privateMembers, GameTime gameTime)
        {
        }