コード例 #1
0
        // Update is called once per frame
        void Update()
        {
            if (Input.GetKeyDown("f10"))
            {
                WindowMng.windowMng.PushView("UI/GMCmd");
            }

            if (Input.touchCount > 0)
            {
                Log.GUI(" Capture Touch Event ");
            }
            if (Input.GetMouseButtonDown(0))
            {
                Log.GUI(" Capture Mouse Event ");
                Log.GUI("Mouse Pos " + Input.mousePosition);

                Log.GUI("Screen " + Screen.width + " " + Screen.height);
            }
            float v = Input.GetAxisRaw("Vertical");
            float h = Input.GetAxisRaw("Horizontal");

            if (Mathf.Abs(v) < 0.1f && Mathf.Abs(h) < 0.1f && VirtualJoystickRegion.VJR != null)
            {
                Vector2 vec = VirtualJoystickRegion.VJRnormals;
                h = vec.x;
                v = vec.y;
            }

            if (ObjectManager.objectManager != null)
            {
                var evt = new MyEvent(MyEvent.EventType.MovePlayer);
                evt.localID = ObjectManager.objectManager.GetMyLocalId();
                evt.vec2    = new Vector2(h, v);
                //MyEventSystem.myEventSystem.PushEvent (evt);
                MyEventSystem.myEventSystem.PushLocalEvent(evt.localID, evt);
            }
        }
コード例 #2
0
 protected override void OnEvent(MyEvent evt)
 {
     if (evt.type == MyEvent.EventType.PlayerEnterWorld)
     {
         player = evt.player;
     }
     else if (evt.type == MyEvent.EventType.PlayerLeaveWorld)
     {
         player = null;
     }
     else if (evt.type == MyEvent.EventType.ShakeCameraStart)
     {
         shakeInitPos = transform.position;
         shakeDir     = transform.TransformDirection(evt.ShakeDir);
         inShake      = true;
     }
     else if (evt.type == MyEvent.EventType.ShakeCameraEnd)
     {
         inShake = false;
     }
     else if (evt.type == MyEvent.EventType.ShakeCamera)
     {
         //Log.Sys("CameraShakeValue "+evt.floatArg+"  dir "+shakeDir+" initPos "+shakeInitPos);
         transform.position = shakeInitPos + shakeDir * evt.floatArg;
     }
     else if (evt.type == MyEvent.EventType.ShowStory)
     {
         scrollDegree = -45;
         inStory      = true;
         AdjustCameraPos();
     }
     else if (evt.type == MyEvent.EventType.EndStory)
     {
         scrollDegree = 0;
         inStory      = false;
     }
 }
コード例 #3
0
 void OnEvent(MyEvent evt)
 {
     //界面需要显示一个Mesh对象
     //TODO: FakeUI在MeshShow的时候需要初始化一下装备显示
     Log.GUI("In Come Event window manager " + evt.type + " " + evt.intArg);
     if (evt.type == MyEvent.EventType.MeshShown)
     {
         FakeObjSystem.fakeObjSystem.OnUIShown(evt.intArg, evt.rolesInfo);
     }
     else if (evt.type == MyEvent.EventType.MeshHide)
     {
         FakeObjSystem.fakeObjSystem.OnUIHide(evt.intArg);
     }
     else if (evt.type == MyEvent.EventType.ChangeScene)
     {
         //切换场景需要弹出所有的UI
         //ClearView ();
     }
     else if (evt.type == MyEvent.EventType.EnterScene)
     {
         //进入场景,清理loading页面
         ClearView();
     }
 }
コード例 #4
0
ファイル: CopyList.cs プロジェクト: itcodes/unityRpg
 protected override void OnEvent(MyEvent evt)
 {
     Log.GUI("Update CopyController Update Gui ");
     UpdateFrame();
 }
コード例 #5
0
 protected override void OnEvent(MyEvent evt)
 {
     UpdateFrame();
 }
コード例 #6
0
ファイル: Bullet.cs プロジェクト: itcodes/unityRpg
        /*
         *客户端表现粒子和服务器计算伤害的数值分离开来
         */
        void OnTriggerEnter(Collider other)
        {
            Log.AI("Bullet collider enemy " + other.name + " " + other.tag);
            if (SkillLogic.IsEnemy(attacker, other.gameObject))
            {
                //攻击多个目标只释放一次 DieParticle
                CreateHitParticle();

                //计算随机的弹射 反射方向
                if (LeftRicochets > 0)
                {
                    Log.AI("Generate new bullet " + LeftRicochets);
                    LeftRicochets--;
                    initPos = transform.position;
                    //子弹应该冲入怪物群中
                    transform.localRotation = Quaternion.Euler(new Vector3(0, transform.localRotation.eulerAngles.y + Random.Range(-missileData.RandomAngle, missileData.RandomAngle), 0));
                    //sleepTime = IgnoreTime;
                }
                else
                {
                    //地震是穿透的因此只会等待粒子自然死亡
                    //非穿透性子弹
                    if (!missileData.piercing)
                    {
                        GameObject.Destroy(gameObject);
                    }
                }

                //伤害多个目标
                if (missileData.IsAOE)
                {
                    AOEDamage();
                }
                else                   //只伤害一个目标
                                       //TODO:通过SkillDamageCaculate计算伤害 Level Information
                {
                    DoDamage(other);
                }

                //非穿透性子弹
                if (!missileData.piercing)
                {
                    var evt = new MyEvent(MyEvent.EventType.EventMissileDie);
                    evt.missile = transform;
                    MyEventSystem.myEventSystem.PushLocalEvent(attacker.GetComponent <KBEngine.KBNetworkView> ().GetLocalId(), evt);
                }
                //TODO::撞击其它玩家如何处理
            }
            else if (other.tag == attacker.tag)
            {
            }
            else                //装到墙体 或者建筑物 等对象身上 则 反射  Not used
            {
                Log.AI("Bullet colldier with Wall " + gameObject.name);
                if (missileData.HitParticle != null)
                {
                    GameObject g = Instantiate(missileData.HitParticle) as GameObject;
                    NGUITools.AddMissingComponent <RemoveSelf> (g);
                    g.transform.position = transform.position;
                    g.transform.parent   = ObjectManager.objectManager.transform;
                }

                if (LeftRicochets > 0)
                {
                    Log.AI("Generate new bullet " + LeftRicochets);
                    LeftRicochets--;
                    initPos = transform.position;
                    transform.localRotation = Quaternion.Euler(new Vector3(0, transform.localRotation.eulerAngles.y + 180 + Random.Range(-missileData.RandomAngle, missileData.RandomAngle), 0));
                    //sleepTime = IgnoreTime;
                }
                else
                {
                    if (!missileData.piercing)
                    {
                        GameObject.Destroy(gameObject);
                    }
                }
                if (!missileData.piercing)
                {
                    var evt = new MyEvent(MyEvent.EventType.EventMissileDie);
                    evt.missile = transform;
                    MyEventSystem.myEventSystem.PushLocalEvent(attacker.GetComponent <KBEngine.KBNetworkView> ().GetLocalId(), evt);
                }
            }
        }
コード例 #7
0
ファイル: Bullet.cs プロジェクト: itcodes/unityRpg
        // Update is called once per frame
        void Update()
        {
            if (isDie)
            {
                return;
            }

            if (missileData.maxTurnRate > 0)
            {
                transform.position     += transform.forward * velocity * Time.deltaTime;
                transform.localRotation = Quaternion.Euler(new Vector3(0, transform.localRotation.eulerAngles.y + Time.deltaTime * Random.Range(-missileData.maxTurnRate, missileData.maxTurnRate), 0));
                //根据目标位置进行旋转计算
            }
            if (missileData.GotoPosition)
            {
                transform.position += transform.forward * velocity * Time.deltaTime;
            }
            else
            {
                transform.position += transform.forward * velocity * Time.deltaTime;
            }

            if ((transform.position - initPos).sqrMagnitude >= maxDistance * maxDistance)
            {
                if (missileData.DieParticle != null)
                {
                    Log.AI("bullet die " + gameObject.name);
                    GameObject g = Instantiate(missileData.DieParticle) as GameObject;
                    NGUITools.AddMissingComponent <RemoveSelf> (g);
                    g.transform.parent   = ObjectManager.objectManager.transform;
                    g.transform.position = transform.position;
                }
                CreateCameraShake();

                isDie = true;
                //正常死亡也有AOE效果
                if (missileData.IsAOE)
                {
                    AOEDamage();
                }

                if (missileData.DieWaitTime > 0)
                {
                    Log.Sys("Wait for time bullet to die");
                    GameObject.Destroy(gameObject, missileData.DieWaitTime);
                }
                else
                {
                    GameObject.Destroy(gameObject);
                }


                var evt = new MyEvent(MyEvent.EventType.EventMissileDie);
                evt.missile = transform;
                if (attacker != null)
                {
                    Log.Sys("Push Missile Die Event " + attacker.GetComponent <KBEngine.KBNetworkView> ().GetLocalId());
                    MyEventSystem.myEventSystem.PushLocalEvent(attacker.GetComponent <KBEngine.KBNetworkView> ().GetLocalId(), evt);
                }
            }
        }
コード例 #8
0
 void HitTarget(MyEvent evt)
 {
     IsDie = true;
 }
コード例 #9
0
        protected override void OnEvent(MyEvent evt)
        {
            var me = ObjectManager.objectManager.GetMyData();

            goldNum.text = "金币: " + me.GetProp(CharAttribute.CharAttributeEnum.GOLD_COIN);
        }
コード例 #10
0
 protected override void OnEvent(MyEvent evt)
 {
     gems.Clear();
     left.SetGems(gems);
     right.SetGems(gems);
 }
コード例 #11
0
        /*
         * Load From Json File PropertyKey
         *
         * No State Code
         * 根据从服务器加载的角色数据来初始化NpcAttribute 中的数值(后续可能需要调整这种方式)
         */

        IEnumerator InitProperty()
        {
            Log.Net("characterinfo   init");
            NetDebug.netDebug.AddConsole("CharacterInfo:: Init Property " + gameObject.name);
            CGGetCharacterInfo.Builder getChar = CGGetCharacterInfo.CreateBuilder();
            getChar.PlayerId = photonView.GetServerID();

            getChar.AddParamKey((int)CharAttribute.CharAttributeEnum.LEVEL);
            getChar.AddParamKey((int)CharAttribute.CharAttributeEnum.EXP);
            getChar.AddParamKey((int)CharAttribute.CharAttributeEnum.GOLD_COIN);
            getChar.AddParamKey((int)CharAttribute.CharAttributeEnum.JING_SHI);

            NetDebug.netDebug.AddConsole("GetChar is " + getChar.ParamKeyCount);

            KBEngine.PacketHolder packet = new KBEngine.PacketHolder();
            yield return(StartCoroutine(KBEngine.Bundle.sendSimple(this, getChar, packet)));

            if (packet.packet.responseFlag == 0)
            {
                var info = packet.packet.protoBody as GCGetCharacterInfo;
                Debug.Log("CharacterInfo::InitProperty " + info);
                foreach (RolesAttributes att in info.AttributesList)
                {
                    if (att.AttrKey == (int)CharAttribute.CharAttributeEnum.GOLD_COIN)
                    {
                        Log.Net("attr int " + att.BasicData.Indicate);
                        Log.Net("attr key " + att.BasicData.TheInt32);
                        Log.Net("attr " + att.ToString());
                    }
                    if (att.BasicData.Indicate == 2)
                    {
                        propertyValue[(CharAttribute.CharAttributeEnum)att.AttrKey] = (int)att.BasicData.TheInt64;
                    }
                    else
                    {
                        propertyValue[(CharAttribute.CharAttributeEnum)att.AttrKey] = att.BasicData.TheInt32;
                    }
                }
            }
            else
            {
                Debug.LogError("CharacterInfo::InitProperty Error");
            }

            var m = GetProp(CharAttribute.CharAttributeEnum.GOLD_COIN);

            Log.Net(m.ToString());

            Log.Important("PropertyValue is " + propertyValue);

            attribute.ChangeLevel(GetProp(CharAttribute.CharAttributeEnum.LEVEL));


            attribute.ChangeHP(0);
            attribute.ChangeMP(0);
            attribute.ChangeExp(0);


            Log.Important("Init HP " + attribute.HP);
            Log.Important("Init Property Over");
            initYet = true;
            NetDebug.netDebug.AddConsole("Init CharacterInfo Over");
            Log.Sys("UpdatePlayerData " + attribute.ObjUnitData.Level);
            var evt = new MyEvent(MyEvent.EventType.UpdatePlayerData);

            evt.localID = attribute.GetLocalId();
            MyEventSystem.myEventSystem.PushEvent(evt);
        }
コード例 #12
0
 void HitTarget(MyEvent evt)
 {
     hitNum++;
 }
コード例 #13
0
ファイル: DetailInfo.cs プロジェクト: itcodes/unityRpg
        protected override void OnEvent(MyEvent evt)
        {
            if (equipData != null)
            {
                var allEquip = BackPack.backpack.GetEquipmentData();
                foreach (var e in allEquip)
                {
                    if (e.id == equipData.id)
                    {
                        SetEquip(e);
                        break;
                    }
                }


                string baseAttr = "";
                if (equipData.itemData.Damage > 0)
                {
                    baseAttr += string.Format("[9800fc]攻击力:{0}[-]\n", equipData.itemData.Damage);
                }
                if (equipData.itemData.RealArmor > 0)
                {
                    baseAttr += string.Format("[8900cf]防御力:{0}[-]\n", equipData.itemData.RealArmor);
                }

                string initAttr = string.Format("[fc0000]天赋攻击:{0}[-]\n[fc0000]天赋防御:{1}[-]\n",
                                                equipData.entry.RndAttack,
                                                equipData.entry.RndDefense);

                string extarAttr = string.Format("[fc0000]额外攻击:{0}[-]\n[fc0000]额外防御:{1}[-]\n",
                                                 equipData.entry.ExtraAttack,
                                                 equipData.entry.ExtraDefense);

                Name.text = string.Format("[ff9500]{0}({1}级)[-]\n[0098fc]{2}金币[-]\n{3}{4}{5}[fcfc00]{6}[-]",
                                          equipData.itemData.ItemName,
                                          equipData.entry.Level,
                                          equipData.itemData.GoldCost,
                                          baseAttr,
                                          initAttr,
                                          extarAttr,
                                          equipData.itemData.Description);
            }
            else if (backpackData != null)
            {
                //GetName("Sell").SetActive(true);
                if (backpackData.itemData.IsEquip())
                {
                    string baseAttr = "";
                    var    itemData = backpackData.itemData;
                    var    entry    = backpackData.packInfo.PackEntry;
                    if (itemData.Damage > 0)
                    {
                        baseAttr += string.Format("[9800fc]攻击力:{0}[-]\n", itemData.Damage);
                    }
                    if (itemData.RealArmor > 0)
                    {
                        baseAttr += string.Format("[8900cf]防御力:{0}[-]\n", itemData.RealArmor);
                    }

                    string initAttr = string.Format("[fc0000]天赋攻击:{0}[-]\n[fc0000]天赋防御:{1}[-]\n",
                                                    entry.RndAttack,
                                                    entry.RndDefense);
                    string extarAttr = string.Format("[fc0000]额外攻击:{0}[-]\n[fc0000]额外防御:{1}[-]\n",
                                                     entry.ExtraAttack,
                                                     entry.ExtraDefense);

                    var cost = "";
                    if (itemData.GoldCost > 0)
                    {
                        cost = string.Format("[0098fc]{0}金币[-]", itemData.GoldCost);
                    }
                    else
                    {
                        cost = string.Format("[0098fc]{0}晶石[-]", itemData.propsConfig.JingShi);
                    }

                    Name.text = string.Format("[ff9500]{0}({1}级)[-]\n{2}\n{3}{4}{5}[fcfc00]{6}[-]",
                                              itemData.ItemName,
                                              entry.Level,
                                              cost,
                                              baseAttr,
                                              initAttr,
                                              extarAttr,
                                              itemData.Description);
                }
                else if (backpackData.itemData.IsGem())
                {
                    var cost     = "";
                    var itemData = backpackData.itemData;
                    if (itemData.GoldCost > 0)
                    {
                        cost = string.Format("[0098fc]{0}金币[-]", itemData.GoldCost);
                    }
                    else
                    {
                        cost = string.Format("[0098fc]{0}金币[-]", itemData.propsConfig.JingShi * 100);
                    }

                    GetName("Equip").SetActive(false);
                    Name.text = string.Format("[ff9500]{0}({1}阶)[-]\n{2}\n[0098fc]数量{3}[-]\n[fcfc00]{4}[-]",
                                              backpackData.itemData.ItemName,
                                              backpackData.itemData.Level,
                                              cost,
                                              backpackData.num,
                                              backpackData.itemData.Description
                                              );
                }
                else if (backpackData.itemData.IsProps())
                {
                    var cost     = "";
                    var itemData = backpackData.itemData;
                    if (itemData.GoldCost > 0)
                    {
                        cost = string.Format("[0098fc]{0}金币[-]", itemData.GoldCost);
                    }
                    else
                    {
                        cost = string.Format("[0098fc]{0}金币[-]", itemData.propsConfig.JingShi * 100);
                    }

                    GetName("Equip").SetActive(false);
                    GetName("LevelUp").SetActive(false);
                    Name.text = string.Format("[ff9500]{0}[-]\n{1}\n[0098fc]数量{2}[-]\n[fcfc00]{3}[-]",
                                              backpackData.itemData.ItemName,
                                              cost,
                                              backpackData.num,
                                              backpackData.itemData.Description
                                              );
                }
                else
                {
                }
            }
        }
コード例 #14
0
 protected override void OnEvent(MyEvent evt)
 {
     Log.GUI("OnEvent " + evt.type);
     UpdateFrame();
 }