コード例 #1
0
    public void OnFinishQuest(int mainQuestId, int subQuestId, bool createNewPref = false)
    {
        FBSoundManager.Play(FBSoundManager.FINISH_SOUND);
        if (createNewPref)
        {
            QuestData q = GroupGameDatabase.instance.getAllConstantQuest().Find(x => (x.mainQuestId == mainQuestId && x.subQuestId == subQuestId));
            if (q != null)
            {
                string     prefName = q.questObjectRewardPref;
                GameObject go       = FBPoolManager.instance.getPoolObject(prefName);
                if (go)
                {
                    go.transform.position = transform.position;
                    go.transform.rotation = transform.rotation;

                    //hide quest object
                    this.gameObject.SetActive(false);

                    go.SetActive(true);
                }
            }
        }
        else
        {
            Transform rewardChild = this.gameObject.transform.findChildRecursively(mainQuestId + "_" + subQuestId);
            if (rewardChild)
            {
                //play anim here

                rewardChild.gameObject.SetActive(true);
            }
        }
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        PhotonNetwork.ConnectUsingSettings(setting);
        var temp = PhotonVoiceNetwork.Client;

        FBSoundManager.PlayMusic("lobby_theme");
        OnInitPlayerOffline();
    }
コード例 #3
0
    public static void ShowWrongSignal(Vector3 pos, float duration = 1f, bool isFollow = true)
    {
        //GameObject go = FBPoolManager.instance.getPoolObject(WRONG_SIGNAL_POPUP, FBPoolManager.POOLTYPE.UI);
        //BasePopup baseScript = go.GetComponent<BasePopup>();
        //baseScript.SetValues(null, isFollow, duration);
        FBSoundManager.Play(FBSoundManager.WRONG_SOUND);
        GameObject go = FBParticleManager.GetEffect("wrong_signal", 2f);

        go.transform.position = pos;
        go.SetActive(true);
    }
コード例 #4
0
    void OnTriggerEnterAXE(Collider other)
    {
        GroupObject obj = other.GetComponent <GroupObject>();

        if (obj && obj.tag == "tree")
        {
            FBParticleManager.PlayEffect(FBParticleManager.HIT_ANIMAL, 2, other.ClosestPoint(this.transform.position));
            FBSoundManager.Play(FBSoundManager.HIT_SOFT);
            obj.UpdateHP(-AXE_DAMAGE);
        }
    }
コード例 #5
0
    // Use this for initialization
    void Start()
    {
        PhotonNetwork.ConnectUsingSettings(setting);
        var temp = PhotonVoiceNetwork.Client;

        FBSoundManager.PlayMusic("BackgroundMusic2");

        //GameObject fx =FBParticleManager.GetEffect("FX_Fire", 2f);
        //if (fx)
        //{
        //    fx.transform.position = Vector3.zero;
        //    fx.SetActive(true);
        //}
    }
コード例 #6
0
ファイル: Player.cs プロジェクト: 1453006/DatLD_MultiPlayerVR
    void OnSwipeUp()
    {
        if (currentHandItem && !isSendShoot)
        {
            FBSoundManager.Play("BallThrow");

            //GameObject fx = FBParticleManager.GetEffect("FX_Fire", 2f);
            //if current hand item is gun
            ObjectInGame scrp = currentHandItem.GetComponent <ObjectInGame>();
            if (scrp && scrp.IsGunObjectInGame())
            {
                isSendShoot = true;
                OnSwipeUpForGun(scrp);

                return;
            }

            if (scrp && scrp.IsMeleetInGame())
            {
                return;// not throw weapon
            }
            isSendSwipe = true;
            currentHandItem.transform.SetParent(null);
            Vector3 endPos = teleportController.selectionResult.selection;
            if (currentPointerGO)
            {
                endPos = currentPointerGO.position;
            }
            Quaternion endRot  = currentHandItem.transform.rotation;
            GameObject newItem = PhotonNetwork.Instantiate("GroupGame/" + currentHandItem.gameObject.name, endPos, endRot, 0);

            //test only delete it
            //fx.transform.position = endPos;
            //fx.SetActive(true);
            //test
            newItem.SetActive(false);
            //another player will see this player hand on nothing
            PhotonView playerPhotonView = visualPlayer.GetPhotonView();
            playerPhotonView.RPC("SendRemoveHandItem", PhotonTargets.Others, playerPhotonView.viewID);

            currentHandItem.transform.DOJump(endPos, 0.5f, 1, 1).OnComplete(() =>
            {
                isSendSwipe = false;
                FBPoolManager.instance.returnObjectToPool(currentHandItem);
                currentHandItem = null;
                newItem.SetActive(true);
            });
        }
    }
コード例 #7
0
 private void CalculateWinAndLoss()
 {
     Debug.Log("calc " + localAnswer + ":" + CalcExpression(this.numberA, this.numberB, this.op));
     if (localAnswer == correctNumber)
     {
         this.result = ResultType.LocalWin;
         FBSoundManager.Play(FBSoundManager.COMBINE_SOUND);
         Debug.Log(" YOU WIN");
     }
     else
     {
         this.result = ResultType.LocalLoss;
         Debug.Log("YOU LOSS");
     }
 }
コード例 #8
0
    public void OnTriggerEnterGunBullet(Collider other)
    {
        //check collide with animal group Object
        GroupObject obj = other.GetComponent <GroupObject>();

        if (obj && obj.tag == "animal")
        {
            FBSoundManager.Play(FBSoundManager.HIT_SOFT);
            obj.UpdateHP(-BULLET_DAMAGE);
        }
        else if (obj)
        {
            PopupManager.ShowWrongSignal(this.transform.position);
        }
        FBPoolManager.instance.returnObjectToPool(this.gameObject);
    }
コード例 #9
0
    void OnTriggerEnterMathBullet(Collider other)
    {
        if (MathGame.instance.isSentMove())
        {
            Debug.Log("SENT MOVE RETURN");
            return;
        }

        if (other.gameObject.name.Contains("Math_Balloon"))
        {
            string answer = other.GetComponentInChildren <TextMesh>().text.Trim();
            int    number = int.Parse(answer);
            MathGame.instance.MakeTurn(number);
            FBParticleManager.PlayEffect("hit_animal", 1f, other.transform.position);
            FBSoundManager.Play(FBSoundManager.POP);
            other.gameObject.SetActive(false);
        }
    }
コード例 #10
0
    void OnCombineObject(CombinationMap map, GameObject item01, GameObject itemDock, ObjectInGame dockManager)
    {
        dockManager.isBusy = true;
        FBPoolManager.instance.returnObjectToPool(item01);
        int  itemFinal = map.ItemIdFinal;
        Item finalObj  = GroupGameDatabase.instance.GetItemByID(itemFinal);

        this.itemDockPos            = itemDock.transform.position;
        dockManager.finalObjectName = finalObj.prefabName;
        //display timer
        FBParticleManager.PlayEffect(FBParticleManager.EFFECT_COMBINE_OBJECT, 2, itemDockPos);
        FBSoundManager.Play(FBSoundManager.COMBINE_SOUND);
        GameObject timerDialog = PopupManager.ShowTimer("Group_Timer", map.Duration, itemDock);

        timerDialog.GetComponent <BasePopup>().eventCompleteTimer += dockManager.ObjectInGame_eventCompleteTimer;


        //fake collect display for another player
        PhotonView playerPhotonView = Player.instance.visualPlayer.GetPhotonView();

        playerPhotonView.RPC("SendFakeCollectItem", PhotonTargets.AllViaServer, playerPhotonView.viewID, itemFinal, itemDock.gameObject.name);
    }
コード例 #11
0
    void OnTriggerEnterQuestObject(Collider other)
    {
        //update quest process data
        ObjectInGame obj = other.GetComponent <ObjectInGame>();
        Transform    pos = this.transform.findChildRecursively("wrong_marker");

        if (obj && obj.isCombinableObject() && other.gameObject.GetPhotonView().viewID == 0)
        {
            SendTriggerQuestItem = true;
            other.gameObject.SetActive(false);
            Item      otherData = other.gameObject.GetComponent <Item>();
            QuestData q         = listQuestData.Find(x => x.requireItemId == otherData.Id);
            if (q != null && !QuestManager.instance.isFinishQuest(q))
            {
                FBPoolManager.instance.returnObjectToPool(other.gameObject);
                QuestManager.instance.UpdateQuestProcess(q, +1);
                FBParticleManager.PlayEffect(FBParticleManager.EFFECT_COMBINE_OBJECT, 2, pos ? pos.position : this.transform.position);
                FBSoundManager.Play(FBSoundManager.COMBINE_SOUND);
                Invoke("ResetSendTrigger", 2f);
            }
            else
            {
                if (pos)
                {
                    PopupManager.ShowWrongSignal(pos.position);
                }
                else
                {
                    PopupManager.ShowWrongSignal(this.transform.position);
                }
            }
        }
        else
        {
            FBPoolManager.instance.returnObjectToPool(other.gameObject);
        }
    }
コード例 #12
0
    void OnTriggerEnterBall(Collider other)
    {
        //check area
        if (other.gameObject == HockeyGame.instance.validArea[0].gameObject ||
            other.gameObject == HockeyGame.instance.validArea[1].gameObject ||
            other.gameObject.name.Contains("Ground"))
        {
            return;
        }
        //check is goal
        if (other.gameObject == HockeyGame.instance.goals[0].gameObject)
        {
            FBSoundManager.Play(FBSoundManager.COMBINE_SOUND);
            HockeyGame.instance.photonView.RPC("AddScore2Players", PhotonTargets.AllViaServer, 1, 1);
            //OnBallRestart();
            return;
        }
        else if (other.gameObject == HockeyGame.instance.goals[1].gameObject)
        {
            FBSoundManager.Play(FBSoundManager.COMBINE_SOUND);
            HockeyGame.instance.photonView.RPC("AddScore2Players", PhotonTargets.AllViaServer, 1, 0);
            //OnBallRestart();
            return;
        }

        Ray ray = new Ray();
        // ObjectInGame objClass = other.GetComponent<ObjectInGame>();
        // if (objClass)
        // {
        //     if (objClass.instance.type == TYPE.Striker)
        //     {
        //

        //     }

        // }
        // else
        // {
        //     currentSpeed *= 0.9f;

        // }
        //check is striker


        float   timeToEnd = 0f;
        Vector3 targetPos = Vector3.zero;
        Vector3 lastPosition;

        //  RaycastHit hit;

        //if (Physics.Raycast(transform.position, transform.TransformDirection(direct), out hit))
        //{
        //    Debug.Log("is raycast");
        //    Debug.DrawLine(transform.position, hit.point);
        //    float dist = Vector3.Distance(transform.position, hit.point);
        //    Debug.Log(" time is :" + speed / dist);
        //    timeToEnd = dist / currentSpeed;
        //    targetPos = hit.point;
        //    transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, Random.Range(15, 30), transform.rotation.eulerAngles.z);
        //    tweenDoMove = transform.DOMove(hit.point, timeToEnd).SetEase(Ease.Linear);
        //}
        Vector3 contact = other.gameObject.GetComponent <Collider>().ClosestPointOnBounds(transform.position);

        if (other.gameObject.name.Contains("Striker"))
        {
            FBSoundManager.Play(FBSoundManager.BALL_BOUNCE);
            currentSpeed = (currentSpeed >= 2 * speed) ? 2 * speed : currentSpeed *= 1.7f;
            if (other.GetComponent <PhotonView>().isMine)
            {
                // direct = /*other.transform.forward;*/(contact - other.transform.position).normalized;
                direct   = contact - other.transform.position;
                direct.y = 0;
                direct.z = Mathf.Abs(direct.z);
                ray      = new Ray(contact, direct);

                RaycastHit hit;
                if (Physics.Raycast(ray.origin, ray.direction, out hit, 100))
                {
                    Debug.Log("is raycast");
                    Debug.DrawLine(transform.position, hit.point);
                    float dist = Vector3.Distance(transform.position, hit.point);
                    //Debug.Log(" time is :" + speed / dist);
                    timeToEnd = dist / currentSpeed;
                    targetPos = hit.point;
                    transform.LookAt(targetPos);
                    transform.DOKill();
                    tweenDoMove = transform.DOMove(hit.point, timeToEnd).SetEase(Ease.Linear);

                    photonView.RPC("AddForceOverNetwork", PhotonTargets.AllViaServer
                                   , targetPos, timeToEnd, PhotonNetwork.time);
                }
            }
        }
        else
        {
            currentSpeed *= 0.9f;
            //direct = Vector3.Reflect(transform.position, contact.normalized);
            direct = Vector3.Reflect(transform.forward, -other.transform.right.normalized);

            direct.y = 0;
            ray      = new Ray(contact, direct);
            Debug.Log("EDGE HIT IS" + ray.origin + "-" + ray.direction);
            FBSoundManager.Play(FBSoundManager.BALL_BOUNCE);
            //if(ray.direction.z == 1 || ray.direction.z == -1 || ray.direction.z == 0)
            //{
            //    float z = ray.direction.z;
            //   ray.direction = new Vector3(ray.direction.x, ray.direction.y,z > 0 ? 0.4f:-0.4f);
            //}
            transform.LookAt(ray.direction * 200f);
            Debug.Log("EDGE ROT IS" + transform.rotation.eulerAngles);
            RaycastHit hit;
            if (Physics.Raycast(ray.origin, ray.direction, out hit, 100))
            {
                Debug.Log("is raycast");
                Debug.DrawLine(transform.position, hit.point);
                float dist = Vector3.Distance(transform.position, hit.point);
                //Debug.Log(" time is :" + speed / dist);
                timeToEnd = dist / currentSpeed;
                targetPos = hit.point;
                transform.LookAt(targetPos);
                transform.DOKill();
                tweenDoMove = transform.DOMove(hit.point, timeToEnd).SetEase(Ease.Linear);

                if (PhotonNetwork.isMasterClient)
                {
                    photonView.RPC("AddForceOverNetwork", PhotonTargets.AllViaServer
                                   , targetPos, timeToEnd, PhotonNetwork.time);
                }
            }
        }

        //RaycastHit hit;

        //if (Physics.Raycast(ray.origin, ray.direction, out hit, 100))//cast the ray 100 units at the specified direction
        //{
        //    //the reflection direction is the reflection of the current ray direction flipped at the hit normal
        //    Vector3 inDirection = Vector3.Reflect(ray.direction, hit.normal);
        //    //cast the reflected ray, using the hit point as the origin and the reflected direction as the direction
        //    ray = new Ray(hit.point, inDirection);

        //    //Draw the normal - can only be seen at the Scene tab, for debugging purposes
        //    Debug.DrawRay(hit.point, hit.normal * 3, Color.blue);
        //    //represent the ray using a line that can only be viewed at the scene tab
        //    Debug.DrawRay(hit.point, inDirection * 100, Color.magenta);

        //    transform.localRotation = Quaternion.Euler(inDirection);
        //    if (Physics.Raycast(ray.origin, ray.direction, out hit, 100))//cast the ray 100 units at the specified direction
        //    {
        //        Debug.Log("is raycast");
        //        Debug.DrawLine(transform.position, hit.point);
        //        float dist = Vector3.Distance(transform.position, hit.point);
        //        //Debug.Log(" time is :" + speed / dist);
        //        timeToEnd = dist / currentSpeed;
        //        targetPos = hit.point;
        //        //  transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, Random.Range(15, 30), transform.rotation.eulerAngles.z);
        //        tweenDoMove = transform.DOMove(hit.point, timeToEnd).SetEase(Ease.Linear);
        //    }
        //}
    }
コード例 #13
0
    public void OnPointerClick(PointerEventData eventData)
    {
        FBSoundManager.Play(FBSoundManager.HIT_SOFT);
        switch (type)
        {
        case TYPE.MathButton:
        {
            Debug.Log("Button clicked");

            Player.instance.SetState(Player.PlayerState.PlayingGame);
            Sequence sequence = DOTween.Sequence();
            sequence.Append(this.transform.DOScaleY(initScaleY * 0.5f, 0.25f).SetEase(Ease.OutSine));
            sequence.Append(this.transform.DOScaleY(initScaleY, 0.5f).SetEase(Ease.OutBounce));

            //answer of math game
            if (!MathGame.instance)
            {
                Debug.Log("MATH GAME NOT FOUND");
                return;
            }

            // make move of math game
            string answer = this.GetComponentInChildren <Text>().text.Trim();
            int    number = int.Parse(answer);
            MathGame.instance.MakeTurn(number);
            break;
        }

        case TYPE.SwitchGameBtn:
        {
            //check num of player
            if (PhotonNetwork.room.PlayerCount != FBTextManager.NUM_START_PLAY)
            {
                PopupManager.ShowText("Waiting for another player", 3f);
                return;
            }

            Player.instance.SetState(Player.PlayerState.PlayingGame);
            Debug.Log("SwitchGameBtn clicked");
            Sequence sequence = DOTween.Sequence();
            sequence.Append(this.transform.DOScaleY(initScaleY * 0.5f, 0.25f).SetEase(Ease.OutSine));
            sequence.Append(this.transform.DOScaleY(initScaleY, 0.5f).SetEase(Ease.OutBounce));
            if (PhotonNetwork.isMasterClient && MiniGameManager.instance.currentGamePrefab == null)
            {
                MiniGameManager.instance.currentGamePrefab = PhotonNetwork.Instantiate(extentGO.name, extentTransform.position, extentTransform.rotation, 0);
                this.gameObject.SetActive(false);
            }


            break;
        }

        case TYPE.WEAPON_MELEE:
        case TYPE.WEAPON_GUN:
        {
            //pickup item script need update
            if (IsHasWeapon())
            {
                return;
            }
            Player.instance.SetState(Player.PlayerState.None);
            PickupAndAttach();
            //UpdateInventory(+1);
            break;
        }

        case TYPE.CombinableObj:
        {
            Player.instance.SetState(Player.PlayerState.None);
            //static object can not be clicked
            if (thisItemData == null || thisItemData.Stackable == -1)
            {
                break;
            }

            PickUp();
            UpdateInventory(+1);
            break;
        }

        case TYPE.SwitchRoomBtn:
        {
            OnSwitchRoomBtnClicked();
            break;
        }

        case TYPE.GoToLobbyBtn:
        {
            OnGoToLobby();
            break;
        }
        }
    }