Esempio n. 1
0
    void OnGUI()
    {
        if (ownerData == null || ownerData.showObjectName == false)
        {
            return;
        }

        if (center != null)
        {
            if (labelStyle == null)
            {
                labelStyle                  = new GUIStyle(GUI.skin.label);
                labelStyle.alignment        = TextAnchor.UpperCenter;
                labelStyle.normal.textColor = Color.black;
                labelStyle.fontSize         = 15;
            }

            Vector3 position = Camera.main.WorldToScreenPoint(transform.position + new Vector3(0, 1, 0));

            float x = position.x - 45;
            float y = Screen.height - position.y;

            string name = ownerData.GetOwner().Name;

            if (ownerData.GetOwner() is Monster)
            {
                MonsterTemplate template = ((Monster)ownerData.GetOwner()).Template;
                name = template.Name;
            }

            GUI.Label(new Rect(x, y, 90, 20), name, labelStyle);
        }
    }
Esempio n. 2
0
        private void NotifyNearbyAggroAdded(Character target)
        {
            if (!GetTemplate().AlertsAllies)
            {
                return;
            }

            if (lastNotify + notifyInterval < Time.time)
            {
                lastNotify = Time.time;
                Collider2D[] colliders = Physics2D.OverlapCircleAll(Owner.GetData().GetBody().transform.position, AggressionRange);

                foreach (Collider2D c in colliders)
                {
                    if (c.gameObject == null)
                    {
                        continue;
                    }

                    AbstractData d = c.gameObject.GetData();

                    if (d == null)
                    {
                        continue;
                    }

                    if (d.GetOwner() is Monster)
                    {
                        Monster monster = (Monster)d.GetOwner();

                        if (monster.AI.State != AIState.ATTACKING)
                        {
                            monster.AI.AddAggro(target, 1);
                            continue;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public static Character GetCharacter(GameObject o)
        {
            AbstractData d = o.GetComponent <AbstractData>();

            if (d == null)
            {
                return(null);
            }

            Character ch = d.GetOwner();

            return(ch);
        }
Esempio n. 4
0
        public static Character GetCharacterFromObject(GameObject obj)
        {
            AbstractData data = obj.GetComponentInParent <AbstractData>();

            if (data == null)
            {
                return(null);
            }

            Character targetCh = data.GetOwner();

            return(targetCh);
        }
Esempio n. 5
0
        public static Character GetChar(this GameObject o)
        {
            AbstractData d = o.GetComponent <AbstractData>();

            if (d == null)
            {
                /*Destroyable dest = o.GetComponent<Destroyable>();
                 * if(dest != null)
                 *      return dest.owner.GetChar();*/
                return(null);
            }

            Character ch = d.GetOwner();

            return(ch);
        }