コード例 #1
0
    private void QuitControl()
    {
        if (Input.GetKeyDown("left") || Input.GetKeyDown(KeyCode.A))
        {
            if (menu_4_affirmative)
            {
                return;
            }

            menu_4_affirmative = true;
            ToggleButton(menu_4_yes, true);
            ToggleButton(menu_4_no, false);
            PlayClickSound();
        }
        if (Input.GetKeyDown("right") || Input.GetKeyDown(KeyCode.D))
        {
            if (!menu_4_affirmative)
            {
                return;
            }

            menu_4_affirmative = false;
            ToggleButton(menu_4_yes, false);
            ToggleButton(menu_4_no, true);
            PlayClickSound();
        }
        if (Input.GetKeyDown("escape"))
        {
            focusStatus = focus.main;
            quitDialog.SetActive(false);
            PlayPageSound();
        }
    }
コード例 #2
0
 private void Quit()
 {
     ToggleButton(menu_4_yes, false);
     ToggleButton(menu_4_no, true);
     menu_4_affirmative = false;
     quitDialog.SetActive(true);
     focusStatus = focus.quit;
 }
コード例 #3
0
 private void ContinueGame(SaveData data)
 {
     StopBgm();
     focusStatus                   = focus.none;
     GameManager.stage             = data.GetStage();
     GameManager.enabledArms       = data.GetEnabledArms();
     GameManager.position          = data.GetPosition();
     GameManager.isLoadingSaveData = true;
     loading_1.SetActive(true);
     stageLoader.LoadStage(GameManager.stage);
 }
コード例 #4
0
 public void setFocus(Control ctr)
 {
     if (ctr.InvokeRequired)
     {
         focus st = new focus(setFocus);
         ctr.Invoke(st, ctr);
     }
     else
     {
         ctr.Focus();
     }
 }
コード例 #5
0
 private void StartNewGame()
 {
     StopBgm();
     focusStatus = focus.none;
     SaveSystem.DeleteSaveFile();
     GameManager.stage             = SaveSystem.initialStage;
     GameManager.enabledArms       = SaveSystem.initialEnabledArms;
     GameManager.position          = SaveSystem.initialPosition;
     GameManager.isLoadingSaveData = false;
     loading_1.SetActive(true);
     stageLoader.LoadStage(GameManager.stage);
 }
コード例 #6
0
 private void SaveDataExistsEnterKey()
 {
     if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown("return"))
     {
         if (menu_2_affirmative)
         {
             StartNewGame();
         }
         else
         {
             focusStatus = focus.main;
         }
         PlayPageSound();
         saveDataExistsDialog.SetActive(false);
     }
 }
コード例 #7
0
    private void NewGame()
    {
        SaveData data = SaveSystem.LoadGame();

        if (data == null)
        {
            StartNewGame();
        }
        else
        {
            ToggleButton(menu_2_yes, false);
            ToggleButton(menu_2_no, true);
            saveDataExistsDialog.SetActive(true);
            focusStatus = focus.saveDataExists;
        }
    }
コード例 #8
0
 private void QuitEnterKey()
 {
     if (Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown("return"))
     {
         if (menu_4_affirmative)
         {
             ExitGame();
             PlayPageSound();
         }
         else
         {
             focusStatus = focus.main;
             PlayPageSound();
             quitDialog.SetActive(false);
         }
     }
 }
コード例 #9
0
    private void LoadGame()
    {
        SaveData data = SaveSystem.LoadGame();

        if (data == null)
        {
            ToggleButton(menu_1_yes, false);
            ToggleButton(menu_1_no, true);
            menu_1_affirmative = false;
            noSaveDataDialog.SetActive(true);
            focusStatus = focus.noSaveData;
        }
        else
        {
            ContinueGame(data);
        }
    }
コード例 #10
0
 private void SettingsControl()
 {
     if (Input.GetKeyDown("up") || Input.GetKeyDown(KeyCode.W))
     {
         Debug.Log("UP");
     }
     if (Input.GetKeyDown("down") || Input.GetKeyDown(KeyCode.S))
     {
         Debug.Log("DOWN");
     }
     if (Input.GetKeyDown("escape"))
     {
         Debug.Log("EXIT");
         focusStatus = focus.main;
         PlayPageSound();
         settingsDialog.SetActive(false);
     }
 }
コード例 #11
0
 private void Settings()
 {
     settingsDialog.SetActive(true);
     focusStatus = focus.settings;
 }
コード例 #12
0
ファイル: testGame.cs プロジェクト: tedavtar/CoinWars
    void CastRayToWorld(Vector2 pos)
    {
        //Debug.Log ("initially: " + clicks);

        Ray r = Camera.main.ScreenPointToRay(pos);
        //Vector3 p = r.origin + r.direction*(10 - (-.17f));
        Vector3    p = Vector3.zero;
        RaycastHit test;
        LayerMask  lm;        //our layermask for raycasting to ignore coins not in turn

        if (turn == 1)        //so p1's turn want to mask out p2 coins. so mask out layer p2
        {
            lm = lm2;         //so lm2 is only layer p2. Then at end invert this.
        }
        else
        {
            lm = lm1;
        }
        lm = ~lm;

        bool       hitCoin = false;
        GameObject coinHit;

        //Debug.Log (lm.value);
        //Debug.Log (r.direction);
        if (Physics.Raycast(r.origin, r.direction, out test, Mathf.Infinity, lm))
        {
            //so need to check if hit a coin. else lower p.y else raise p.y (because if it's a coin then we're going to miss it if we incrase the ray's height..

            /*namely we know from that default unity cylinder primitive = 2 units high
             * this means due to .1 scale our coins are .2 units high so .2/2 = .1, the half height of interest.
             */
            p = test.point;

            GameObject gotHit = test.collider.gameObject;
            //Vector3 adjust = gotHit.transform.up;//so the normal of the surface that was hit
            //so need to make adjust to be terrain normal now..



            if (!gotHit.name.StartsWith("Terrain"))
            {
                if (clicks == 0)
                {
                    focus coinF = gotHit.GetComponent <focus>();
                    if (!coinF)
                    {
                        return;
                    }
                    coinF.handleSelection();
                    return;
                }

                //p.y -= .1f;//
                //Vector3 adjust = gotHit.transform.up; //try something else b/c when coin upside down, we get 0 -1 0 rather than 0 1 0.
                Vector3 adjust = test.normal;
                adjust.Normalize();


                //Debug.Log ("p prev: " + p);
                p += -.1f * adjust;               //AHA! So that's why. Adjust is being negative b/c coin is flipped over.
                //Debug.Log(adjust);
                //Debug.Log ("p adjusted: " + p + " and adjustment used: " + adjust);
                //Debug.Log("On a coin");
            }
            else                //so need the Terrain normal - credit to Eric on unity forumns
                                //p.y += .1f;

            /*
             * Terrain t = gotHit.GetComponent<Terrain>();
             * Vector3 relPos = p - t.transform.position;
             * Vector2 nPos = new Vector2(Mathf.InverseLerp(0.0f, t.terrainData.size.x, relPos.x), Mathf.InverseLerp(0.0f, t.terrainData.size.z, relPos.z));
             *
             * Vector3 adjust = t.terrainData.GetInterpolatedNormal(nPos.x,nPos.y);
             */
            //adjust = adjust.normalized;
            {
                deselectAllCoins();
                GameObject.Find("P1Merger").GetComponent <coinMerger>().clearLines();
                GameObject.Find("P2Merger").GetComponent <coinMerger>().clearLines();               //added



                //now if this coin has reachable pipeline emphasized(coin selected + pressed "S") and clicked on
                //a reachable segment, then teleport to some height above grid cell center (for now--later animate/lerp/rotate/roll)
                //and then reset clicks to 0 and return (not sure need to set to 0 as in already would be set to 0???)
                if (gotHit.GetComponent <SnapGrid>() != null)               // && storePipes.teleportationInitiated){
                {
                    SnapGrid sg = gotHit.GetComponent <SnapGrid>();
                    if (sg.selected)
                    {
                        //Debug.Log(sg.finalPosition[0]+.5f);
                        if (sg.owner == 1)
                        {
                            Vector3 teleportLoc = Vector3.zero;
                            teleportLoc.x = sg.finalPosition[0] + .5f;
                            teleportLoc.z = sg.finalPosition[1] + .5f;
                            storePipes.CoinThatCanTeleport.transform.position = teleportLoc;
                            storePipes.clearTeleportation();
                            storePipes.clearTeleportationP2();
                            clicks = 0;
                            return;                            //added
                        }
                        else
                        {
                            Vector3 teleportLoc = Vector3.zero;
                            teleportLoc.x = sg.finalPosition[0] + .5f;
                            teleportLoc.z = sg.finalPosition[1] + .5f;
                            storePipes.CoinThatCanTeleportP2.transform.position = teleportLoc;
                            storePipes.clearTeleportation();
                            storePipes.clearTeleportationP2();
                            clicks = 0;
                            return;
                        }
                    }
                }
                else
                {
                    storePipes.clearTeleportation();
                    storePipes.clearTeleportationP2();
                }

                Vector3 adjust = test.normal;
                adjust.Normalize();

                p += .1f * adjust;
                //Debug.Log("On the floor");
                //Debug.Log(adjust);
                //Debug.Log(gotHit.transform.up); aha, so transform.up gives the normal. need to use this for adjustment so that will work also on inclined surfaces,not just flat ones w/ normal of 0 1 0
            }
        }


        if (clicks == 0)
        {
            clickPos = p;
            clicks  += 1;
            //Debug.Log("h " + clicks);//added
        }
        else
        {
            clicks = 0;
            Vector3 dir = p - clickPos;

            //k so here rather than debug dray ray do a line renderer so viewer can see in scene

            StartCoroutine(drawLine(clickPos, p, 1.0f));

            Debug.DrawRay(clickPos, dir, Color.blue, 5.0f);
            RaycastHit hit;
            float      dist = dir.magnitude;
            if (Physics.Raycast(clickPos, dir, out hit, dist, lm))
            {
                GameObject target = hit.collider.gameObject;


                coinAndroidTest info = target.GetComponent <coinAndroidTest>();
                //if (info.owner != turn){return;} // so exit if WAIT NO use raycast layber bitmask and here just check for locked/set it if false to true and increment a var to decide if turn over
                if (!info)
                {
                    return;
                }
                if (info.locked)                //so this coin is locked meaning have already launched it
                {
                    return;
                }
                info.toggleLocked(true);
                info.locked = true;                 //so we're going to launch this so need to lock it so can't double launch in same turn


                Rigidbody coin = target.GetComponent <Rigidbody>();

                float distToHit = Vector3.Distance(hit.point, clickPos);

                float ratio = distToHit / dist;
                //Debug.Log("N/D: " + ratio);


                Vector3 offset = hit.point - coin.position;

                float offsetsize = offset.magnitude;
                //Debug.Log(offsetsize); offset = useless for coins--always = .5. For pencilwars (original) it had meaning...

                forceFactor = target.GetComponent <coinAndroidTest>().forceFactor;

                Vector3 forceToAdd = dir.normalized * ratio * forceFactor;                // * Mathf.Pow (offsetsize,spower);
                //Debug.Log(coin.name + forceToAdd);
                coin.AddForceAtPosition(forceToAdd, hit.point);
            }
        }

        //Debug.Log ("at the end: " + clicks);
    }
コード例 #13
0
ファイル: driver_focus.cs プロジェクト: zjmit/go2cs
 var(focus, err)     = compileRegexOption("focus", v["focus"].value, null);
コード例 #14
0
        public override void Update(InputMngr inputMngr)
        {
            switch (currentFocus)
            {
            case focus.profileCheck:
            {
                if (profileMngr.getProfileNum() > 0)
                {
                    currentFocus = focus.profileSel;
                    break;
                }

                if (ProfileMngr.currentProfile == null)
                {
                    if (firstPass == true)
                    {
                        setProfileCheckUI();
                    }

                    UiMngr.checkInput(gridOne, inputMngr);
                }
                else
                {
                    throw new Exception("Something went wrong with the profile manager.");
                }
            }
            break;

            case focus.profileSel:
            {
                if (firstPass == true)
                {
                    setProfileSelUI();
                    setProfileSelListUI();
                }

                switch (subCurrentFocus)
                {
                case subFocus.profileSel:
                {
                    UiMngr.checkInput(gridOne, inputMngr);

                    if (inputMngr.checkInput(controls.goTestTri) == true)
                    {
                        stateMngr.setCRTState(States.StateMngr.ARstate.AR_Launch, assetMngr);
                    }

                    if (inputMngr.checkInput(controls.pressEnd) == true)
                    {
                        display.changeDisplay();
                    }
                }
                break;

                case subFocus.profileSelList:
                {
                    UiMngr.checkInput(gridProfileSel, inputMngr);

                    if (inputMngr.checkInput(controls.pressBack) == true)
                    {
                        subCurrentFocus = subFocus.profileSel;
                    }
                }
                break;
                }
            }
            break;

            case focus.osti:
            {
                OSTI.Update(inputMngr);

                if (OSTI.getDone() == true)
                {
                    profileName = OSTI.getText();

                    OSTI.setActive(false);

                    if (profileMngr.checkForProfile(profileName) == false)
                    {
                        profileMngr.createProfile(profileName); currentFocus = focus.profileSel;
                    }

                    else
                    {
                        Console.WriteLine("Profile Already Exists.");
                        OSTI = new OnScreenTextInput(); OSTI.setActive(true);
                    }
                }
            }
            break;
            }
        }