// -------------------
        public InteractiveObjectBase FindInteractiveObjectFor(CharacterAction chara)
        {
            InteractiveObjectBase
                nearestObj = null;
            float
                nearestObjDistSq = 0;



            for (int i = 0; i < this.interactiveObjectList.Count; ++i)
            {
                InteractiveObjectBase o = this.interactiveObjectList[i];
                if ((o == null) || !o.IsNear(chara))
                {
                    continue;
                }

                float distSq = (chara.transform.position - o.transform.position).sqrMagnitude;

                if ((nearestObj == null) || (distSq < nearestObjDistSq))
                {
                    nearestObj       = o;
                    nearestObjDistSq = distSq;
                }
            }

            return(nearestObj);
        }
示例#2
0
        // --------------------
        public void PerformAction()
        {
            if (this.levelData == null)
            {
                return;
            }

            InteractiveObjectBase
                obj = this.levelData.FindInteractiveObjectFor(this);

            if (obj != null)
            {
                if (!string.IsNullOrEmpty(this.actionAnimatorTrigger) && (this.animator != null))
                {
                    this.animator.SetTrigger(this.actionAnimatorTrigger);
                }

                obj.OnCharacterAction(this);
            }
        }