public void UnuseLooks() { if (UIResState == ResState.Loaded && LooksNode != null) { LooksNode.gameObject.SetActive(false); ResMgr.GetInstance().UnuseGameObject("Nameboard", LooksNode.gameObject); UIResState = ResState.WaitLoad; LooksNode = null; } }
private void HandleHurtEvent(SprotoType.scene_hurt_event_info hurtEvent) { // long uid = hurtEvent.attacker_uid; var entityMgr = SceneMgr.Instance.EntityManager; if (hurtEvent.defenders == null || hurtEvent.defenders.Count <= 0) { return; } for (int i = 0; i < hurtEvent.defenders.Count; i++) { var defender = hurtEvent.defenders[i]; // Debug.Log("defender uid : "+defender.uid+" count:"+hurtEvent.defenders.Count+" damage:"+defender.damage+" hp:"+defender.cur_hp+" damagetype:"+defender.flag); var defenderEntity = SceneMgr.Instance.GetSceneObject(defender.uid); // Debug.Log("has health : "+entityMgr.HasComponent<HealthStateData>(defenderEntity)); if (defenderEntity.Equals(Entity.Null) || ECSHelper.IsDead(defenderEntity, entityMgr)) { continue; } if (entityMgr.HasComponent <LocomotionState>(defenderEntity)) { //进入受击状态 bool playBehit = UnityEngine.Random.RandomRange(0, 100) > 90.0f; if (playBehit) { var locomotionState = entityMgr.GetComponentData <LocomotionState>(defenderEntity); locomotionState.LocoState = LocomotionState.State.BeHit; locomotionState.StartTime = Time.time; entityMgr.SetComponentData <LocomotionState>(defenderEntity, locomotionState); } //显示战斗飘字 var defenderTrans = entityMgr.GetComponentObject <Transform>(defenderEntity); var flyWordObj = ResMgr.GetInstance().GetGameObject("FightFlyWord"); FightFlyWord flyWord = flyWordObj.GetComponent <FightFlyWord>(); flyWord.SetData(defender.change_num, defender.flag); var pos = defenderTrans.position; pos += Vector3.up * 1; flyWord.transform.SetParent(UnityMMO.SceneMgr.Instance.FlyWordContainer); flyWord.transform.position = pos; flyWord.StartFly(); } ChangeHP(defenderEntity, defender.cur_hp, defender.flag, hurtEvent.attacker_uid); } }
public void StartFly() { var randomX = Random.RandomRange(-1.0f, 1.0f); var randomY = Random.RandomRange(1.5f, 2.5f); var randomZ = Random.RandomRange(-1.0f, 1.0f); var randomMoveDuration = Random.RandomRange(0.5f, 1.0f); var moveAction = Cocos.MoveBy.CreateAbs(randomMoveDuration, new Vector3(randomX, randomY, randomZ)); var fadeOutAction = Cocos.FadeOut.Create(0.7f, Cocos.ColorAttrCatcherTextMeshPro.Ins); var delayFadeoutAction = Cocos.Sequence.Create(Cocos.DelayTime.Create(0.5f), fadeOutAction); var spawnAction = Cocos.Spawn.Create(moveAction, delayFadeoutAction); var action = Cocos.Sequence.Create(spawnAction, Cocos.CallFunc.Create(() => { // Object.Destroy(gameObject, 0.1f); gameObject.SetActive(false); Cocos.Helper.SetOpacity(transform, 1, Cocos.ColorAttrCatcherTextMeshPro.Ins); ResMgr.GetInstance().UnuseGameObject("FightFlyWord", gameObject); })); runner.PlayAction(action); }
public void OnDestroy() { Instance = null; }