/* * When Birth is inattackable * Birth Add Buff UnAttackable */ public void OnHit(GameObject go, int damage, bool isCritical, bool isStaticShoot, SkillData.DamageType damageType = SkillData.DamageType.Physic, bool showHit = true) { if (attribute != null && attribute._characterState != CharacterState.Birth) { lastAttacker = go.GetComponent <NpcAttribute>().GetNetView().GetServerID(); if (attackerList.ContainsKey(lastAttacker)) { attackerList[lastAttacker] += damage; } else { attackerList.Add(lastAttacker, damage); } CacheDamage.Add(new DamageData(go, damage, isCritical, isStaticShoot, damageType, showHit)); onHit = true; attacker = go; var evt = new MyEvent(MyEvent.EventType.OnHit); evt.attacker = attacker; MyEventSystem.myEventSystem.PushLocalEvent(photonView.GetLocalId(), evt); } }
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; } }
// 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); } }
/// <summary> /// 初始化特定事件发生时候的技能层 /// 或者 创建孩子技能 /// </summary> /// <param name="item">Item.</param> /// <param name="evt">Evt.</param> void InitLayout(SkillDataConfig.EventItem item, MyEvent evt) { if (item.layout != null) { var g = Instantiate(item.layout) as GameObject; g.transform.parent = transform; //陷阱粒子效果 位置是 当前missile爆炸的位置 //瞬间调整SkillLayout的方向为 攻击者的正方向 g.transform.localPosition = InitPos; float y; if (forwardSet) { y = Quaternion.LookRotation(forwardDir).eulerAngles.y; } else { y = attacker.transform.localRotation.eulerAngles.y; } g.transform.localRotation = Quaternion.Euler(new Vector3(0, y, 0)); g.transform.localScale = Vector3.one; var runner = g.AddComponent <SkillLayoutRunner>(); runner.stateMachine = this; runner.Event = item; runner.triggerEvent = evt; allRunners.Add(g); Log.AI("SkillLayout " + item.layout.name); } else if (item.childSkillId != 0 && item.childSkillId != -1) { Log.AI("Create Child Skill " + item.childSkillId); SkillLogic.CreateSkillStateMachine(attacker, Util.GetSkillData(item.childSkillId, 1), evt.missile.position); } }
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(); } }
// 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); } } }
/* *客户端表现粒子和服务器计算伤害的数值分离开来 */ void HitSomething(Collider other) { Log.AI("Bullet collider enemy " + other.name + " " + other.tag); if (SkillLogic.IsEnemyForBullet(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); } } }
protected override void OnEvent(MyEvent evt) { SetData(ScoreManager.Instance.score); }
/* *客户端表现粒子和服务器计算伤害的数值分离开来 */ private void HitSomething(Collider other) { Log.AI("Bullet collider enemy " + other.name + " " + other.tag); var otherAttr = NetworkUtil.GetAttr(other.gameObject); if (otherAttr != null && otherAttr.gameObject == attacker) { return; } if (SkillLogic.IsEnemyForBullet(attacker, other.gameObject)) { var oattr = NetworkUtil.GetAttr(other.gameObject); if (oattr != null) { var buff = oattr.GetComponent <BuffComponent>(); var fanTan = buff.CheckHasSuchBuff(Affix.EffectType.FanTanBullet); Log.Sys("CheckHasSuchBuff: " + fanTan); if (fanTan && fanTanNum == 0) { fanTanNum++; var dirY = transform.localRotation.eulerAngles.y; transform.localRotation = Quaternion.Euler(new Vector3(0, dirY + 180, 0)); this.runner.stateMachine.attacker = oattr.gameObject; var l2 = Util.FindChildRecursive(this.transform, "blue"); if (l2 != null) { l2.gameObject.SetActive(false); var l3 = Util.FindChildRecursive(this.transform, "red"); l3.gameObject.SetActive(true); } return; } } //攻击多个目标只释放一次 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)); } else { //地震是穿透的因此只会等待粒子自然死亡 //非穿透性子弹 if (!missileData.piercing) { GameObject.Destroy(gameObject); } } //伤害多个目标 if (missileData.IsAOE) { AOEDamage(); } else { 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 { //装到墙体 或者建筑物 等对象身上 则 反射 Not used Log.AI("Bullet colldier with Wall " + other.name); 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 + 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; if (attacker != null) { MyEventSystem.myEventSystem.PushLocalEvent( attacker.GetComponent <KBEngine.KBNetworkView>().GetLocalId(), evt); } } } }
protected override void OnEvent(MyEvent evt) { gems.Clear(); left.SetGems(gems); right.SetGems(gems); }
public void SetData(Dictionary <int, ScoreData> score) { var gameOver = WorldManager.worldManager.GetActive().state == SceneState.GameOver; //游戏结束不要更新榜单了 if (gameOver) { return; } while (cells.Count < score.Count) { var g = Object.Instantiate(cell) as GameObject; g.transform.parent = cell.transform.parent; Util.InitGameObject(g); cells.Add(g); g.SetActive(false); } foreach (var c in cells) { c.SetActive(false); } var keys = score.Keys.ToList(); keys.Sort((a, b) => { var ad = score[a]; var bd = score[b]; if (ad.killed > bd.killed) { return(-1); } if (ad.killed < bd.killed) { return(1); } return(0); }); var rank = 0; var myId = NetMatchScene.Instance.myId; var myLocalId = ObjectManager.objectManager.GetMyLocalId(); for (var i = 0; i < keys.Count; i++) { var k = keys[i]; var player = ObjectManager.objectManager.GetPlayer(k); if (player != null) { var un = player.GetComponent <NpcAttribute>().userName; if (!string.IsNullOrEmpty(un)) { ScoreManager.Instance.UpdateCacheName(k, un); var g = cells[i]; g.SetActive(true); g.GetComponent <ScoreCell>().SetData(rank + 1, un, score[k].killed, score[k].serverId); rank++; if (rank == 1) { var evt = new MyEvent(MyEvent.EventType.IAmFirst); evt.intArg = k; MyEventSystem.myEventSystem.PushEvent(evt); } } } else { ScoreManager.Instance.RemoveCacheName(k); } } StartCoroutine(WaitReset()); }
protected override void OnEvent(MyEvent evt) { Log.GUI("OnEvent " + evt.type); UpdateFrame(); }
protected override void OnEvent(MyEvent evt) { UpdateFrame(); }
void HitTarget(MyEvent evt) { IsDie = true; WindowMng.windowMng.ShowNotifyLog("核弹已经释放,请立即逃离该区域", 4, null, true); }
void HitTarget(MyEvent evt) { hitNum++; }
protected override void OnEvent(MyEvent evt) { InitChat(); }
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 { } } }
/* * 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); }
protected override void OnEvent(MyEvent evt) { var me = ObjectManager.objectManager.GetMyData(); goldNum.text = "金币: " + me.GetProp(CharAttribute.CharAttributeEnum.GOLD_COIN); }
void HitTarget(MyEvent evt) { IsDie = true; }
void OnEvent(MyEvent evt) { }
protected override void OnEvent(MyEvent evt) { Log.GUI("Update CopyController Update Gui "); UpdateFrame(); }