public int WeaponIndex; //角色当前武器ID //战斗中 //目标置入初始状态. public void Init(MeteorUnit Unit) { EventBus = new EventBus(); Player = Unit; WaitState = new WaitState(this); IdleState = new IdleState(this); GuardState = new GuardState(this); KillState = new KillState(this); PatrolState = new PatrolState(this); ReviveState = new ReviveState(this); FollowState = new FollowState(this); FightOnGroundState = new FightOnGroundState(this); FightOnAirState = new FightOnAirState(this); LookState = new LookState(this); DodgeState = new DodgeState(this); FindState = new FindState(this); FaceToState = new FaceToState(this); PickUpState = new PickUpState(this); LeaveState = new LeaveState(this); InitFightWeight(); int dis = Player.Attr.View; DistanceFindUnit = dis * dis; DistanceMissUnit = (dis + dis / 2) * (dis + dis / 2); this.EnterDefaultState(); stoped = false; }
public void Init(MeteorUnit target) { //GameObject.Destroy(Main.Instance.playerListener); //Main.Instance.playerListener = gameObject.AddComponent<AudioListener>(); UnitTarget = target; Target = target.transform; animationPlay = false; animationTick = 0.0f; followHeight = 6; followDistance = 55.0f; BodyHeight = 30; m_MinSize = 60; LookAtAngle = 10.0f; m_Camera = GetComponent <Camera>(); m_Camera.fieldOfView = m_MinSize; fRadis = Mathf.Sqrt((followDistance * followDistance + followHeight * followHeight)); lastAngle = Mathf.Atan2(followHeight, followDistance) * Mathf.Rad2Deg; if (target != null) { CameraLookAt.position = new Vector3(Target.position.x, Target.position.y + BodyHeight, Target.position.z); CameraPosition.position = new Vector3(0, followHeight, 0) + CameraLookAt.position + followDistance * (Target.forward); transform.position = CameraPosition.position; Vector3 vdiff = CameraLookAt.position - transform.position; transform.rotation = Quaternion.LookRotation(new Vector3(vdiff.x, 0, vdiff.z), Vector3.up); } }
//public void Begin(Vector3 pos, int soul, OnFinished onFinished) //{ // transform.position = pos; // mSoulValue = soul; // mTarget = UnitManager.Instance.LocalPlayer; // mMoveState = EMoveState.Rise; // mOnFinished = onFinished; // iTween.MoveTo(gameObject, iTween.Hash( // "y", transform.position.y + RiseHeight, // "time", RiseTime, // "easetype", iTween.EaseType.easeOutCubic, // "oncomplete", "RiseComplete")); //} public void ldaBegin(MeteorUnit attacker, Vector3 pos, int soul, GameObject coin, OnFinished onFinished) { //mCoin = coin; transform.position = pos; mSoulValue = soul; mTarget = attacker; mMoveState = EMoveState.Rise; mOnFinished = onFinished; float rvalue = Random.value * 0.2f; if (Random.Range(0, 10) > 5) { MovingTime += rvalue; } else { MovingTime -= rvalue; } iTween.MoveTo(gameObject, iTween.Hash( "y", transform.position.y, //+ RiseHeight, "time", 0, //RiseTime, "easetype", iTween.EaseType.easeOutCubic, "oncomplete", "RiseComplete")); }
public void OnSFXDestroy(MeteorUnit unit, Collider co) { if (DamageList.ContainsKey(unit)) { DamageList[unit].Remove(co); } }
//如果是空,标志着,锁定目标已经被消灭 public void ChangeLockedTarget(MeteorUnit unit) { if (unit == null) { if (lockedEffect != null) { lockedEffect.OnPlayAbort(); lockedEffect = null; } lockedTarget = null; bLocked = false; } else { if (autoEffect != null) { autoEffect.OnPlayAbort(); autoEffect = null; } autoTarget = null; lockedTarget = unit; lockedEffect = SFXLoader.Instance.PlayEffect("lock.ef", lockedTarget.gameObject); bLocked = true; } if (FightWnd.Exist) { FightWnd.Instance.OnChangeLock(bLocked); } }
public void OnUnitDead(MeteorUnit unit) { if (leftTime.ContainsKey(unit)) { leftTime.Remove(unit); } }
public void Jump(MeteorUnit Owner, Vector2 jumpVec, float ShortsScale, bool Short = true) { Owner.SetJumpVelocity(jumpVec); if (jumpVec.y != 0) { if (jumpVec.y > 0) { Owner.Jump(Short, ShortsScale, CommonAction.Jump); } else { Owner.Jump(Short, ShortsScale, CommonAction.JumpBack); } } else if (jumpVec.x != 0) { if (jumpVec.x > 0) { Owner.Jump(Short, ShortsScale, CommonAction.JumpRight); } else { Owner.Jump(Short, ShortsScale, CommonAction.JumpLeft); } } else if (jumpVec == Vector2.zero) { Owner.Jump(Short, ShortsScale); } }
//public void DestroyCoin(GameObject obj) //{ // Coins.Remove(obj); //} //public void AddCoin(GameObject coin) //{ // Coins.Add(coin); //} //public void AddDropThing(GameObject obj) //{ // DropThing.Add(obj); //} public void OnGenerateUnit(MeteorUnit unit, int playerId = 0) { if (UnitInfos.Contains(unit)) { Debug.LogError("unit exist"); return; } ////让角色间无法穿透,待某个角色使出特殊技能时,关掉碰撞。 //for (int i = 0; i < UnitInfos.Count; i++) // UnitInfos[i].PhysicalIgnore(unit, false); if (CombatData.Ins.GLevelMode == LevelMode.MultiplyPlayer) { unit.InstanceId = playerId; } else { unit.InstanceId = UnitInstanceIdx; if (IsFirstMember(unit)) { unit.IsLeader = true; } UnitInstanceIdx++; } UnitInfos.Add(unit); }
public void UpdateMonsterInfo(MeteorUnit mon) { if (!Main.Ins.GameStateMgr.gameStatus.ShowBlood) { return; } if (!TargetBlood.activeInHierarchy) { TargetBlood.SetActive(true); } if (CurrentMonster == mon) { nextTargetHp = mon.Attr.hpCur; TargetHPLabel.text = ((int)(mon.Attr.hpCur / 10.0f)).ToString() + "/" + ((int)(mon.Attr.TotalHp / 10.0f)).ToString(); CheckHideTarget = true; TargetInfoLast = 5.0f; return; } CheckHideTarget = true; TargetInfoLast = 5.0f; TargetHp.fillAmount = (float)mon.Attr.hpCur / (float)mon.Attr.TotalHp; TargetHPLabel.text = ((int)(mon.Attr.hpCur / 10.0f)).ToString() + "/" + ((int)(mon.Attr.TotalHp / 10.0f)).ToString(); currentTargetHp = mon.Attr.hpCur; nextTargetHp = mon.Attr.hpCur; TargetName.text = mon.name; CurrentMonster = mon; }
//场景物件按照0点防御来算. int CalcDamage(MeteorUnit attacker, AttackDes attack = null) { //(((武器攻击力 + buff攻击力) x 招式攻击力) / 100) - (敌方武器防御力 + 敌方buff防御力) / 10 //你的攻击力,和我的防御力之间的计算 //attacker.damage.PoseIdx; if (GameStateMgr.Ins.gameStatus.EnableGodMode) { return(100000); } int DefTmp = 0; AttackDes atk = attacker.CurrentDamage; if (atk == null) { atk = attack; } if (atk == null) { Debug.LogError("CalcDamage can not find attackdes"); return(1); } int WeaponDamage = attacker.CalcDamage(); int PoseDamage = MenuResLoader.Ins.FindOpt(atk.PoseIdx, 3).second[0].flag[6]; int BuffDamage = attacker.Attr.CalcBuffDamage(); int realDamage = Mathf.FloorToInt((((WeaponDamage + BuffDamage) * PoseDamage) / 100.0f - (DefTmp))); return(realDamage); }
public void OnUnitDead(MeteorUnit unit) { if (!UnitInfos.Contains(unit)) { Debug.LogError("unit not registered"); } unit.OnUnitDead(null); UnitInfos.Remove(unit); DeadUnits.Add(unit); //角色死亡,导致其他角色统统检查目标是否是无效的。 for (int i = 0; i < UnitInfos.Count; i++) { UnitInfos[i].OnUnitDead(unit); } MapArea[] area = GameObject.FindObjectsOfType <MapArea>(); if (area != null && area.Length != 0) { for (int i = 0; i < area.Length; i++) { area[i].OnUnitDead(unit); } } //由RemoveNpc处理删除尸体. //if (unit.Attr != null) // GameObject.Destroy(unit.gameObject, 5.0f); }
public void Drop(MeteorUnit player) { //player.Attr; //List<GameObject> obj = new List<GameObject>(); //一定爆出角色主武器,有Flag爆出Flag,并且这个Flag,会持续一定时间,若无人拾取,则会重置Flag归位. int mainWeapon = player.Attr.Weapon; ItemDatas.ItemDatas ib = Main.Ins.DataMgr.GetData <ItemDatas.ItemDatas>(mainWeapon); WeaponDatas.WeaponDatas wb = U3D.GetWeaponProperty(ib.UnitId); GameObject trigget = CreateTriggerObj(wb.WeaponR, player.transform, -player.transform.forward); //obj.Add(trigget); //ExplosionObject01.iTweenExplosion01(1, ref obj, player.transform.position); ExplosionObject01.DropItem(trigget, player.transform.position, -player.transform.forward); //如果角色拥有第二武器,那么第一武器扔掉时,切换到第二武器 player.DropAndChangeWeapon(); //扔掉Flag道具 if (player.GetFlag) { trigget = CreateObj(player.GetFlagItem.model, player.transform, -player.transform.forward); ExplosionObject01.DropItem(trigget, player.transform.position, Quaternion.AngleAxis(30, Vector3.up) * -player.transform.forward); player.SetFlag(null, 0); } }
void MovetoTarget(MeteorUnit target) { //if (pathIdx == -1 && !FreeCache.ContainsKey(followTarget) && Vector3.Distance(owner.transform.position, followTarget.mPos) > 40.0f) //{ // int FreeSlot = -1; // targetPath = GameBattleEx.Instance.FindPath(owner.transform.position, followTarget, out FreeSlot); // pathIdx = 0; // targetPos = followTarget.transform.position; //} //tick = 0.0f; owner.FaceToTarget(target); if (Vector3.Distance(new Vector3(owner.mPos.x, 0, owner.mPos.z), new Vector3(target.mPos.x, 0, target.mPos.z)) <= 35) { owner.controller.Input.AIMove(0, 0); if (Status == EAIStatus.Kill) { SubStatus = EAISubStatus.KillGetTarget; } else if (Status == EAIStatus.Follow) { Status = EAIStatus.Idle; SubStatus = EAISubStatus.Think; } return; } else { if (SubStatus == EAISubStatus.KillGetTarget) { SubStatus = EAISubStatus.KillGotoTarget; } } owner.controller.Input.AIMove(0, 1); }
public override void OnStart() { for (int i = 1; i < 9; i++) { string s = string.Format("npc31_0{0}", i); AddNPC(s); } AddNPC("npc31_13"); Vector3 vec = CombatData.Ins.GLevelSpawn[14]; vec.x += 375; U3D.MovePlayer("高寄萍", vec); U3D.RotatePlayer("高寄萍", -90); int player = U3D.GetChar("player"); MeteorUnit uplayer = U3D.GetUnit(player); if (uplayer != null) { vec = CombatData.Ins.GLevelSpawn[14]; vec.x += 415; vec.y = uplayer.transform.position.y; U3D.MovePlayer("player", vec); U3D.RotatePlayer("player", 90); } //强制AI进入各区域 for (int i = 1; i < 9; i++) { base.TeamBTransferToArena(i, i - 1); } base.OnStart(); }
public void OnTriggerStay(Collider other) { MeteorUnit unit = null; switch (type) { case MapAreaType.Fire: unit = other.gameObject.transform.root.GetComponent <MeteorUnit>(); if (unit != null && !unit.Dead) { if (leftTime.ContainsKey(unit)) { leftTime[unit] -= Time.deltaTime; if (leftTime[unit] <= 0.0f) { //不是熔岩骷髅则死 //if (unit != null) // unit.AddBuff(0); leftTime[unit] = freq; } } } break; } }
void HideTargetInfo() { TargetBlood.SetActive(false); CheckHideTarget = false; CurrentMonster = null; TargetInfoLast = 5.0f; }
public void OnTriggerExit(Collider other) { MeteorUnit unit = null; switch (type) { case MapAreaType.Die: unit = other.gameObject.transform.root.GetComponent <MeteorUnit>(); //不是熔岩骷髅则死 if (unit != null && !unit.Dead) { unit.OnDead(); UpdateUI(unit); } break; case MapAreaType.Fire: unit = other.gameObject.transform.root.GetComponent <MeteorUnit>(); if (leftTime.ContainsKey(unit)) { leftTime.Remove(unit); } break; } }
public void LoadAttack(InventoryItem weapon, Vector3 forward, AttackDes att, MeteorUnit Owner) { owner = Owner; _attack = att; WeaponRoot = new GameObject().transform; WeaponRoot.SetParent(transform); WeaponRoot.localPosition = Vector3.zero; WeaponRoot.localScale = Vector3.one; WeaponRoot.localRotation = Quaternion.Euler(0, 180, 90); WeaponRoot.name = "WeaponRoot"; WeaponRoot.gameObject.layer = gameObject.layer; Weapon = weapon; LoadWeapon(); transform.LookAt(transform.position + forward); MeshRenderer mr = gameObject.GetComponentInChildren <MeshRenderer>(); hitBox = mr.gameObject.AddComponent <BoxCollider>(); hitBox.isTrigger = true; hitBox.size = new Vector3(6, 3, 6); _speed = InitializeSpeed; velocity = forward * InitializeSpeed; addVelocity = true; if (U3D.showBox) { BoundsGizmos.Instance.AddCollider(hitBox); } //取消这个对象和同队或者自己的碰撞 if (owner != null) { owner.IgnoreOthers(hitBox); } }
public void OnCollisionEnter(Collision collision) { MeteorUnit unit = null; switch (type) { case MapAreaType.Die: unit = collision.gameObject.transform.root.GetComponent <MeteorUnit>(); if (unit != null && !unit.Dead) { unit.OnDead(); UpdateUI(unit); } break; case MapAreaType.Fire: unit = collision.gameObject.transform.root.GetComponent <MeteorUnit>(); if (unit != null && !unit.Dead) { unit.GetItem(11); UpdateUI(unit); } break; } }
//float step = 0.05f; //float FadeIn = 0.1f; public override void OnInspectorGUI() { base.OnInspectorGUI(); MeteorUnit myTarget = (MeteorUnit)target; way = GUILayout.TextField(way); action = GUILayout.TextField(action); if (GUILayout.Button("GetWayIndex")) { wayIndex = PathMng.Ins.GetWayIndex(myTarget.mSkeletonPivot); way = wayIndex.ToString(); } if (GUILayout.Button("GetWayIndex2")) { wayIndex = PathMng.Ins.GetWayIndex(myTarget.mSkeletonPivot); way = wayIndex.ToString(); } if (GUILayout.Button("FaceToTarget")) { if (vecTarget == null) { vecTarget = GameObject.Find("facetotarget"); } if (vecTarget == null) { return; } myTarget.StateMachine.ChangeState(myTarget.StateMachine.FaceToState, vecTarget.transform.position); } if (GUILayout.Button("ChangeAction")) { int act = int.Parse(action); myTarget.ActionMgr.ChangeAction(act, 0.1f); } //if (GUILayout.Button("BakeAnimation")) { // int act = int.Parse(action); // myTarget.ActionMgr.BakePose(act); //} if (GUILayout.Button("StopAllAction")) { } if (GUILayout.Button("SampleFrame")) { //PoseState FadeOutState = myTarget.ActionMgr.AddState(0);//从原先的动作 //FadeInState.SetEnabled(true); //FadeInState.SetNormalizedTime(FadeIn); //FadeInState.SetWeight(1); //FadeOutState.SetEnabled(true); //FadeOutState.SetNormalizedTime(1 - FadeIn); //FadeOutState.SetWeight(1); //FrameReplay.deltaTime = Time.deltaTime; //FrameReplay.Instance.time += Time.deltaTime; } }
public void MoveOnCrouch(MeteorUnit Owner, Vector2 moveVec) { if (moveVec.y != 0) { if (moveVec.y > 0 && Owner.posMng.mActiveAction.Idx != CommonAction.CrouchForw) { Owner.posMng.ChangeAction(CommonAction.CrouchForw); } else if (moveVec.y < 0 && Owner.posMng.mActiveAction.Idx != CommonAction.CrouchBack) { Owner.posMng.ChangeAction(CommonAction.CrouchBack); } return; } if (moveVec.x != 0) { if (moveVec.x > 0 && Owner.posMng.mActiveAction.Idx != CommonAction.CrouchRight) { Owner.posMng.ChangeAction(CommonAction.CrouchRight); } else if (moveVec.x < 0 && Owner.posMng.mActiveAction.Idx != CommonAction.CrouchLeft) { Owner.posMng.ChangeAction(CommonAction.CrouchLeft); } } }
//处理动作最后一帧要做的事 public static void HandlerFinalActionFrame(MeteorUnit owner, int Action) { if (LastEvents == null) { LastEvents = new List <int>() { (int)FrameEvent.ChangeWeapon0, (int)FrameEvent.ChangeWeapon1, (int)FrameEvent.ChangeWeaponPos0, (int)FrameEvent.ChangeWeaponPos5, (int)FrameEvent.ChangeWeaponPose570_0, (int)FrameEvent.ChangeWeaponPose451_0, (int)FrameEvent.ChangeWeaponPos7, (int)FrameEvent.RebornFriend }; } if (!LastEvents.Contains(Action)) { return; } switch ((FrameEvent)Action) { case FrameEvent.ChangeWeaponPos7: //收刀切换为居合最后一帧 owner.ChangeWeaponPos(WeaponPos.PosB); break; //0拔刀1长枪2居合 case FrameEvent.ChangeWeaponPos0: owner.ChangeWeaponPos(WeaponPos.PosA); //owner.ChangeWeaponPos(2); break; //case FrameEvent.ChangeWeaponPos2: // owner.ChangeWeaponPos(0); // break; //case FrameEvent.ChangeWeaponPos3: // owner.ChangeWeaponPos(2); // break; case FrameEvent.ChangeWeaponPos8: owner.ChangeWeaponPos(WeaponPos.PosB); break; case FrameEvent.ChangeWeaponPos5: owner.ChangeWeaponPos(WeaponPos.PosA); break; case FrameEvent.ChangeWeapon0: //左打虎 case FrameEvent.ChangeWeapon1: //右打虎 owner.ChangeNextWeapon(); break; case FrameEvent.ChangeWeaponPose570_0: owner.ChangeWeaponPos(WeaponPos.PosA); break; case FrameEvent.ChangeWeaponPose451_0: owner.ChangeWeaponPos(WeaponPos.Pos); break; case FrameEvent.RebornFriend: owner.RebornFriend(); break; } }
//清理角色的攻击盒. public void ClearDamageCollision(MeteorUnit unit) { if (DamageList.ContainsKey(unit)) { DamageList.Remove(unit); } }
// Use this for initialization void Start() { mCacheTransform = transform; mCacheRenderer = GetComponent <Renderer>(); mInitOffset = mCacheTransform.localPosition; mOwner = mCacheTransform.parent.GetComponent <MeteorUnit>(); }
public void SetDebugText() { begintime = Time.time; MeteorUnit unit = gameObject.GetComponent <MeteorUnit>(); if (Panel == null) { Vector3 vecPos = transform.position; Panel = GameObject.Instantiate(Resources.Load("BubbleTalk"), vecPos, Quaternion.identity) as GameObject; vecPos.y += 15.0f; iTween.MoveTo(Panel, iTween.Hash( "position", vecPos, "time", 0.5f, "easetype", iTween.EaseType.linear, "delay", 0.0f)); Panel.transform.SetParent(gameObject.transform); } TheCamera = Camera.main.transform; label = Panel.GetComponentInChildren <Text>(); if (label != null) { label.text = strText; } Transform t = label.transform; Bounds b = NGUIMath.CalculateRelativeWidgetBounds(t); Vector3 scale = t.localScale; b.min = Vector3.Scale(b.min, scale); b.max = Vector3.Scale(b.max, scale); //bgSprite.transform.localScale = new Vector3(b.size.x,b.size.y,1f); }
void InsertPlayerResult(string name_, GameBattleEx.BattleResultItem result) { GameObject obj = GameObject.Instantiate(Resources.Load <GameObject>("ResultItem"));; obj.transform.SetParent(result.camp == 1 ? MeteorResult : ButterflyResult); obj.layer = MeteorResult.gameObject.layer; obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; Text Idx = ldaControl("Idx", obj).GetComponent <Text>(); Text Name = ldaControl("Name", obj).GetComponent <Text>(); //Text Camp = ldaControl("Camp", obj).GetComponent<Text>(); Text Killed = ldaControl("Killed", obj).GetComponent <Text>(); Text Dead = ldaControl("Dead", obj).GetComponent <Text>(); Idx.text = (result.id + 1).ToString(); Name.text = name_; //Camp.text = result.camp == 1 "" Killed.text = result.killCount.ToString(); Dead.text = result.deadCount.ToString(); MeteorUnit u = U3D.GetUnit(result.id); if (u != null) { if (u.Dead) { Idx.color = Color.red; Name.color = Color.red; Killed.color = Color.red; Dead.color = Color.red; } } }
public void Init(MonsterEx attr, Transform attach, EUnitCamp camp) { owner = attach.GetComponent <MeteorUnit>(); Info = GetComponentInChildren <UnitDebugInfo>(true); Info.SetOwner(owner); //Transform mainCanvas = GameObject.Find("Canvas").transform; //transform.SetParent(mainCanvas); transform.localScale = Vector3.one; transform.localRotation = Quaternion.identity; transform.localPosition = Vector3.zero; transform.SetAsLastSibling(); //rect.anchoredPosition3D = new Vector3(0, 40.0f, 0); //transform.localScale = Vector3.one * 0.1f;//0.07-0.03 0.07是主角与敌人距离最近时,0.03是摄像机与敌人最近时,摄像机与敌人最近时,要看得到敌人,必须距离 44左右 MonsterName.text = attr == null ? "" : attr.Name; if (camp == EUnitCamp.EUC_ENEMY) { MonsterName.color = Color.red; } else if (camp == EUnitCamp.EUC_NONE) { MonsterName.color = Color.white; } target = attach; if (owner == Main.Ins.LocalPlayer) { MonsterName.gameObject.SetActive(false); } }
void OnFollowEnemy(bool follow) { if (watchAi != follow) { watchAi = follow; if (watchAi) { //找到第一个未死亡的敌对角色 MeteorUnit watchTarget = null; for (int i = 0; i < Main.Ins.MeteorManager.UnitInfos.Count; i++) { if (Main.Ins.MeteorManager.UnitInfos[i].Dead) { continue; } if (Main.Ins.MeteorManager.UnitInfos[i].SameCamp(Main.Ins.LocalPlayer)) { continue; } watchTarget = Main.Ins.MeteorManager.UnitInfos[i]; break; } Main.Ins.GameBattleEx.InitFreeCamera(watchTarget); Main.Ins.GameBattleEx.EnableFollowCamera(false); Main.Ins.MainCamera = Main.Ins.CameraFree.m_Camera; } else { Main.Ins.GameBattleEx.EnableFollowCamera(true); Main.Ins.GameBattleEx.EnableFreeCamera(false); Main.Ins.MainCamera = Main.Ins.CameraFollow.m_Camera; } } }
void InsertPlayerResult(int instance, int id, int killed, int dead, EUnitCamp camp) { GameObject obj = GameObject.Instantiate(Resources.Load <GameObject>("ResultItem")); if (CombatData.Ins.GGameMode == GameMode.MENGZHU) { obj.transform.SetParent(BattleResult.transform); } else { obj.transform.SetParent(camp == EUnitCamp.EUC_FRIEND ? MeteorResult : ButterflyResult); } obj.layer = MeteorResult.gameObject.layer; obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one; obj.transform.localPosition = Vector3.zero; Text Idx = Control("Idx", obj).GetComponent <Text>(); Text Name = Control("Name", obj).GetComponent <Text>(); if (CombatData.Ins.GGameMode == GameMode.MENGZHU) { } else { Text Camp = Control("Camp", obj).GetComponent <Text>(); Camp.text = U3D.GetCampStr(camp); } Text Killed = Control("Killed", obj).GetComponent <Text>(); Text Dead = Control("Dead", obj).GetComponent <Text>(); Idx.text = (id + 1).ToString(); MeteorUnit unit = U3D.GetUnit(instance); Name.text = unit == null ? "[无名氏]":unit.name; Killed.text = killed.ToString(); Dead.text = dead.ToString(); MeteorUnit u = U3D.GetUnit(id); if (u != null) { if (u.Dead) { Idx.color = Color.red; Name.color = Color.red; Killed.color = Color.red; Dead.color = Color.red; } } else { //得不到信息了。说明该NPC被移除掉了 Idx.color = Color.red; Name.color = Color.red; Killed.color = Color.red; Dead.color = Color.red; } }
public void SetDebugText() { begintime = Time.time; MeteorUnit unit = gameObject.GetComponent <MeteorUnit>(); if (Panel == null) { Vector3 vecPos = transform.position; Panel = GameObject.Instantiate(Resources.Load("BubbleTalk"), vecPos, Quaternion.identity) as GameObject; vecPos.y += 15.0f; //iTween.MoveTo(Panel, iTween.Hash( // "position", vecPos, // "time", 0.5f, // "easetype", iTween.EaseType.linear, // "delay", 0.0f)); Panel.transform.SetParent(gameObject.transform); GetComponentInChildren <Canvas>().worldCamera = GameObject.Find("CameraEx").GetComponent <Camera>(); } TheCamera = Camera.main.transform; label = Panel.GetComponentInChildren <Text>(); if (label != null) { label.text = strText; } Panel.transform.localScale = new Vector3(25.0f / (label.preferredWidth + 20), 10.0f / (label.preferredHeight + 10), 1.0f); //Transform t = label.transform; //Bounds b = NGUIMath.CalculateRelativeWidgetBounds(t); //Vector3 scale = t.localScale; //b.min = Vector3.Scale(b.min, scale); //b.max = Vector3.Scale(b.max, scale); }