public void Initialize(ClientSideObject parent, ushort maxhp, ushort maxmp, byte level, float offset, byte faction) { this.parent = parent; this.offset = offset; hpSlider = transform.FindChild("HP").GetComponent <Slider>(); hpSlider.maxValue = maxhp; mpSlider = transform.FindChild("MP").GetComponent <Slider>(); mpSlider.maxValue = maxmp; if (faction == 0) { transform.FindChild("HP/Fill Area/Fill").gameObject.GetComponent <Image>().color = Color.blue; } else if (faction == 1) { transform.FindChild("HP/Fill Area/Fill").gameObject.GetComponent <Image>().color = Color.red; } else { transform.FindChild("HP/Fill Area/Fill").gameObject.GetComponent <Image>().color = Color.yellow; } SetPositionAndValue(); transform.FindChild("Text").gameObject.GetComponent <Text>().text = level.ToString(); }
public bool WallStand(ClientSideObject target) { Vector3 origin = new Vector3(GetXPos(), 0.5f, GetZPos()); Vector3 goal = new Vector3(target.GetXPos(), 0.5f, target.GetZPos()); Ray ray = new Ray(origin, goal - origin); RaycastHit hit; return(Physics.Raycast(ray, out hit, Vector3.Distance(goal, origin), wallLayerMask)); }
public static void AddBullet(Bullet bullet) { ClientSideObject src = GetObject(bullet.srcObjID); ClientSideObject dest = GetObject(bullet.destObjID); if (src != null && dest != null && src.IsVisible() && dest.IsVisible()) { GameObject prefab = GameObject.Instantiate(Resources.Load("Prefabs/Bullet")) as GameObject; prefab.GetComponent <BulletScript>().Initialize(src.GetSrcBulletPos(), dest.GetDestBulletPos()); } }
public void Initialize(ClientSideObject parent, ushort maxhp, float offset, byte faction) { this.parent = parent; this.offset = offset; slider = GetComponent <Slider>(); slider.maxValue = maxhp; if (faction == 0) { transform.FindChild("Fill Area/Fill").gameObject.GetComponent <Image>().color = Color.blue; } else if (faction == 1) { transform.FindChild("Fill Area/Fill").gameObject.GetComponent <Image>().color = Color.red; } else { transform.FindChild("Fill Area/Fill").gameObject.GetComponent <Image>().color = Color.yellow; } SetPositionAndValue(); }
public void SetParent(ClientSideObject parent) { this.parent = parent; }
public float Distance(ClientSideObject target) { return(Vector2.Distance(new Vector2(target.GetXPos(), target.GetZPos()), new Vector2(this.GetXPos(), this.GetZPos())) - target.GetRadius() - this.GetRadius()); }