private void ReceiveModuleColorChange(NetIncomingMessage msg) { Player owner = GetPlayer(msg.ReadInt32()); HpBarControl control = owner.Device.GetControlOfType <HpBarControl>(); control.Bar.Color = msg.ReadColor(); }
/// <summary> /// vytvori hraci action bar, input manager a zbrane a bazi nebo mining module /// </summary> /// <param name="p">hrac kteremu se maji vytvorit objekty</param> private void CreateActiveObjectsOfPlayer(Player p) { if (p.IsActivePlayer()) { p.CreateWeapons(); p.Baze = SceneObjectFactory.CreateBase(this, p); BaseIntegrityBar ellipse = SceneObjectFactory.CreateBaseIntegrityBar(this, p); HpBarControl control = new HpBarControl(ellipse); p.Baze.AddControl(control); DelayedAttachToScene(ellipse); DelayedAttachToScene(p.Baze); } else { if (p.Device == null) { MiningModule obj = SceneObjectFactory.CreateMiningModule(this, p.Data.MiningModuleStartPos, p); DelayedAttachToScene(obj); DelayedAttachToScene(SceneObjectFactory.CreateMiningModuleIntegrityBar(this, obj, p)); p.Device = obj; } } if (p.IsCurrentPlayer()) { actionBarMgr = new ActionBarMgr(this); StateMgr.AddGameState(actionBarMgr); if (p.IsActivePlayer()) { inputMgr = new PlayerInputMgr(p, this, actionBarMgr); actionBarMgr.CreateActionBarItems(p.GetActions <IPlayerAction>(), false); InitAutomaticMineLauncher(); } else { if (p.Device.HasControlOfType <MiningModuleControl>()) { return; } MiningModuleControl mc = new MiningModuleControl(); mc.Owner = p; p.Device.AddControl(mc); inputMgr = new SpectatorInputMgr(p, this, p.Device, actionBarMgr); actionBarMgr.CreateActionBarItems(p.GetActions <ISpectatorAction>(), true); SceneObjectFactory.CreateSpectatorActionReadinessIndicators(p); } } }
private HpBarControl hpControl; // 血條控制器 #region 事件 private void Start() { rig = GetComponent <Rigidbody>(); // 剛體欄位 = 取得原件<泛型>() ani = GetComponent <Animator>(); // target = GameObject.Find("目標").GetComponent<Transform>(); // 寫法1 target = GameObject.Find("目標").transform; // 寫法2 joy = GameObject.Find("虛擬搖桿").GetComponent <Joystick>(); levelManager = FindObjectOfType <LevelManager>(); // 透過類型尋找物件 hpControl = transform.Find("血條系統").GetComponent <HpBarControl>(); // 變形.尋找("子物件") }
private void Start() { // 先取得元件 ani = GetComponent <Animator>(); agent = GetComponent <NavMeshAgent>(); agent.speed = data.speed; hp = data.hpMax; player = GameObject.Find("玩家").transform; agent.SetDestination(player.position); hpControl = transform.Find("血條系統").GetComponent <HpBarControl>(); hpControl.UpdateHpBar(data.hpMax, hp); }
/// <summary> /// je potreba inicializovat az v updatu, protoze HpBar (Arc) se vytvari a pridava az kdyz je Module hotovy /// </summary> private void TryInitOffsets() { if (initializedOffsets) { return; } HpBarControl c = me.GetControlOfType <HpBarControl>(); if (c != null) { rightBottomOffset = (c.Bar as MiningModuleIntegrityBar).Radius * 2; leftTopOffset = rightBottomOffset / 2 - (me as MiningModule).Radius; initializedOffsets = true; } }
public static MiningModuleIntegrityBar CreateMiningModuleIntegrityBar(SceneMgr mgr, MiningModule module, Player owner) { MiningModuleIntegrityBar arc = new MiningModuleIntegrityBar(mgr, IdMgr.GetNewId(mgr.GetCurrentPlayer().GetId())); arc.Color = owner.Data.SpecialColor; arc.Radius = module.Radius + 5; CenterCloneControl pControl = new CenterCloneControl(module); arc.AddControl(pControl); HpBarControl hControl = new HpBarControl(arc); module.AddControl(hControl); arc.SetGeometry(SceneGeometryFactory.CreateArcSegments(arc)); return(arc); }
public void setSide(int fside,int roleid,Vector3 pos,Vector3 rotate) { side = fside; roledata = new DRoleData(roleid); // GameObject rolemodel = UnityEditor.AssetDatabase.LoadAssetAtPath("Assets/RPG/actors/" + roledata.defaultRoledata.modelUrl + ".prefab",typeof(GameObject)) as GameObject; GameObject rolemodel = ResourceManager.loadAsset<GameObject>("Assets/RPG/actors/" + roledata.defaultRoledata.modelUrl + ".prefab"); roleModel = GameObject.Instantiate(rolemodel) as GameObject; //agent = roleModel.GetComponent<NavMeshAgent>(); roleModel.transform.position = pos; roleModel.transform.parent = transform; //if(fside == 0) // roleModel.tag = Tags.enemy; rolelastpos = pos; roleModel.transform.localEulerAngles = rotate; // roleModel.transform.localScale = new Vector3(8, 8, 8); animatorControl = roleModel.AddComponent<DAnimatorController>(); cc = roleModel.GetComponent<CharacterController>(); bodyRadius = cc.radius; bodyHeight = cc.height; cc.enabled = false; agent = roleModel.AddComponent<NavMeshAgent>(); // obstacle = roleModel.AddComponent<NavMeshObstacle>(); agent.obstacleAvoidanceType = ObstacleAvoidanceType.NoObstacleAvoidance; agent.autoRepath = true; agent.radius = bodyRadius; agent.height = bodyHeight; // obstacle.radius = bodyRadius; // obstacle.carving = true; skillManager = gameObject.AddComponent<FightRoleSkill>(); skillManager.initSkill(roledata.defaultRoledata.skillIdList); followfight = gameObject.AddComponent<FollowFighter>(); hpbarui = gameObject.AddComponent<HpBarControl>(); StartCoroutine(resetModelPos()); }