private void Shoot()
    {
        //shoot
        GameObject bullet = FBPoolManager.instance.getPoolObject("Math_Gun_BULLET");

        if (bullet)
        {
            Transform shootMarker = transform.findChildRecursively("shoot_marker");
            if (shootMarker)
            {
                bullet.transform.position = shootMarker.position;
            }
            else
            {
                bullet.transform.position = transform.position;
            }

            bullet.transform.rotation = transform.rotation;

            Rigidbody    rb     = bullet.addMissingComponent <Rigidbody>();
            ObjectInGame script = bullet.addMissingComponent <ObjectInGame>();
            script.type = TYPE.MathBullet;

            rb.velocity = Vector3.zero; //reset force
            bullet.SetActive(true);
            rb.AddForce(transform.forward * BULLETSTRENGTH, ForceMode.Impulse);

            canshoot = false;
        }
    }
    void OnTriggerEnterCombinaleObject(Collider other)
    {
        //static object cannot collect or collide with other
        if (thisItemData == null || thisItemData.Stackable == -1)
        {
            return;
        }
        ObjectInGame obj = other.GetComponent <ObjectInGame>();

        if (obj && obj.isCombinableObject() && !other.gameObject.GetPhotonView())
        {
            if (this.isBusy || obj.isBusy)
            {
                return;
            }
            Item           thisData  = this.gameObject.GetComponent <Item>();
            Item           otherData = other.gameObject.GetComponent <Item>();
            CombinationMap map       = GroupGameDatabase.instance.getCombinationMapById(thisData.Id);
            if (map != null && this.photonView.viewID == 0)
            {
                if (map.ItemId01 == thisData.Id && map.ItemId02 == otherData.Id)
                {
                    OnCombineObject(map, this.gameObject, other.gameObject, obj);
                }
                else if (map.ItemId01 == otherData.Id && map.ItemId02 == thisData.Id)
                {
                    OnCombineObject(map, other.gameObject, this.gameObject, this);
                }
                else
                {
                    PopupManager.ShowWrongSignal(this.gameObject.transform.position);
                }
            }
        }
    }
Example #3
0
    void InitQuestObject()
    {
        dicQuestObject = new Dictionary <int, ObjectInGame>();
        foreach (Quest q in  listQuest)
        {
            string    goName = q.questData.questObjectName;
            Transform trf    = null;
            trf = gameProbs.transform.findChildRecursively(goName);
            if (trf)
            {
                ObjectInGame cond = null;
                dicQuestObject.TryGetValue(q.questData.mainQuestId, out cond);
                if (cond != null)
                {
                    continue;
                }

                GameObject   go     = trf.gameObject;
                ObjectInGame goCtrl = go.addMissingComponent <ObjectInGame>();
                goCtrl.type       = ObjectInGame.TYPE.QuestObject;
                goCtrl.extentData = q.questData.mainQuestId.ToString();

                go.addMissingComponent <BoxCollider>();

                dicQuestObject.Add(q.questData.mainQuestId, goCtrl);

                InitTutorialQuest(trf, q.questData.mainQuestId);
            }
        }
    }
Example #4
0
    public void OnFinishQuest(Quest q)
    {
        //update Board GUI
        ObjectInGame go = null;

        dicQuestObject.TryGetValue(q.questData.mainQuestId, out go);
        if (go)
        {
            go.OnFinishQuest(q.questData.mainQuestId, q.questData.subQuestId);
        }
    }
Example #5
0
    void UpdateTutorialObject(int mainQuestId, int subQuestId, int num)
    {
        ObjectInGame obj = null;

        dicQuestObject.TryGetValue(mainQuestId, out obj);
        if (!obj)
        {
            return;
        }

        obj.GetComponentInChildren <PopupTutorial>().UpdateQuestProgress(mainQuestId, subQuestId, num);
    }
Example #6
0
    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);
            });
        }
    }
    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);
    }
    public void throwBullet()
    {
        string     gunName = this.gameObject.name.Replace("(Clone)", "");
        GameObject bullet  = FBPoolManager.instance.getPoolObject(gunName + "_BULLET");

        if (!bullet)
        {
            return;
        }

        ObjectInGame bulletController = bullet.addMissingComponent <ObjectInGame>();

        bulletController.type = TYPE.WEAPON_GUN_BULLET;
        Transform spawnPoint = this.transform.findChildRecursively("spawn_point");

        if (spawnPoint)
        {
            bullet.transform.position = spawnPoint.position;
            bullet.transform.rotation = spawnPoint.rotation;
        }

        bullet.SetActive(true);
    }
Example #9
0
    void SendQuestObjectChangeStage(int questIndex)
    {
        Quest q = listQuest[questIndex];

        if (q != null)
        {
            int          mainQuestId = q.questData.mainQuestId;
            ObjectInGame obj         = null;
            dicQuestObject.TryGetValue(mainQuestId, out obj);
            if (!obj)
            {
                return;
            }
            if (obj.name.Contains("Prepare"))
            {
                obj.OnFinishQuest(q.questData.mainQuestId, q.questData.subQuestId, true);
            }
            else
            {
                obj.OnFinishQuest(q.questData.mainQuestId, q.questData.subQuestId);
            }
        }
    }
    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);
        }
    }
Example #11
0
 private void Awake()
 {
     instance   = this;
     correctPos = this.transform.position;
     correctRot = this.transform.rotation;
 }
Example #12
0
    void OnTriggerEnterBall(Collider other)
    {
        //check area
        if (other.gameObject == HockeyGame.instance.validArea[0].gameObject ||
            other.gameObject == HockeyGame.instance.validArea[1].gameObject)
        {
            return;
        }
        //check is goal
        if (other.gameObject == HockeyGame.instance.goals[0].gameObject)
        {
            HockeyGame.instance.photonView.RPC("AddScore2Players", PhotonTargets.AllViaServer, 1, 1);
            return;
        }
        else if (other.gameObject == HockeyGame.instance.goals[1].gameObject)
        {
            HockeyGame.instance.photonView.RPC("AddScore2Players", PhotonTargets.AllViaServer, 1, 0);
            return;
        }

        Vector3 contact = other.gameObject.GetComponent <Collider>().ClosestPointOnBounds(transform.position).normalized;

        direct   = Vector3.Reflect(transform.position, contact);
        direct.y = 0;

        ObjectInGame objClass = other.GetComponent <ObjectInGame>();

        if (objClass)
        {
            if (objClass.instance.type == TYPE.Striker)
            {
                currentSpeed = (currentSpeed >= 2 * speed) ? 2 * speed : currentSpeed *= 1.7f;
            }
        }
        else
        {
            currentSpeed *= 0.9f;
        }

        float      timeToEnd = 0f;
        Vector3    targetPos = Vector3.zero;
        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);
        }


        if (PhotonNetwork.isMasterClient)
        {
            photonView.RPC("AddForceOverNetwork", PhotonTargets.AllViaServer
                           , targetPos, timeToEnd, PhotonNetwork.ServerTimestamp);
        }
    }
Example #13
0
 public void getColor(ObjectInGame pBody)
 {
     pBody.gsColor = 0;
     pBody.gameObject.GetComponent <Renderer>().material.color = Color.red;
     pBody.gsPoints = 10;
 }
Example #14
0
 public void getColor(ObjectInGame pBox)
 {
     pBox.gsColor = 3;
     pBox.gameObject.GetComponent <Renderer>().material.color = Color.yellow;
     pBox.gsPoints = 0;
 }
Example #15
0
 public void getColor(ObjectInGame pBox)
 {
     pBox.gsColor = 4;
     pBox.gameObject.GetComponent <Renderer>().material.color = Color.black;
     pBox.gsPoints = 30;
 }
Example #16
0
 void OnSwipeUpForGun(ObjectInGame objectScrp)
 {
     //swipe up to throw bullet from gun
     objectScrp.throwBullet();
 }