Пример #1
0
        /*
         * public CollisionDataObject CheckExternal( GameObject _object )
         * {
         *      if( _object == null )
         *              return null;
         *
         *      CollisionDataObject _current_collision = null;
         *
         *      foreach( CollisionDataObject _collision in Collisions )
         *      {
         *              if( _collision.Enabled && _collision.Type == ImpactType.EXTERN )
         *                      _current_collision = _collision;
         *      }
         *
         *      if( _current_collision != null && _current_collision.ForceInteraction )
         *      {
         *              Target.TargetGameObject = _object;
         *              Target.TargetOffset.z = 2;
         *              Target.TargetStopDistance = 2;
         *              Target.TargetRandomRange = 0;
         *              Target.BehaviourModeKey = _current_collision.BehaviourModeKey;
         *      }
         *
         *      return _current_collision;
         * }*/

        public CollisionDataObject CheckCollision(Collision _collision)
        {
            if (_collision == null || _collision.collider == null)
            {
                return(null);
            }

            string _tag           = _collision.collider.tag;
            int    _layer         = _collision.collider.gameObject.layer;
            int    _current_total = 0;

            CollisionDataObject _current_impact = null;

            foreach (CollisionDataObject _impact in Collisions)
            {
                if (_impact.Enabled)
                {
                    int _total = 0;

                    if (_impact.LayerPriority > 0 && _impact.Layer == _layer && (_current_impact == null || _impact.LayerPriority > _current_impact.LayerPriority))
                    {
                        _total += _impact.LayerPriority;
                    }

                    if (_impact.TagPriority > 0 && _impact.Tag == _tag && (_current_impact == null || _impact.TagPriority > _current_impact.TagPriority))
                    {
                        _total += _impact.TagPriority;
                    }

                    if (_total > _current_total)
                    {
                        _current_total  = _total;
                        _current_impact = _impact;
                    }
                }
            }

            if (_current_impact != null && _current_impact.ForceInteraction)
            {
                Target.TargetGameObject   = _collision.collider.gameObject;
                Target.TargetOffset.z     = 2;
                Target.TargetStopDistance = 2;
                Target.TargetRandomRange  = 0;
                Target.BehaviourModeKey   = _current_impact.BehaviourModeKey;
            }

            return(_current_impact);
        }
        public void Copy(CollisionDataObject _object)
        {
            if (_object == null)
            {
                return;
            }

            base.Copy(_object);

            UseTag           = _object.UseTag;
            UseLayer         = _object.UseLayer;
            UseBodyPart      = _object.UseBodyPart;
            Name             = _object.Name;
            ForceInteraction = _object.ForceInteraction;
            Tag                 = _object.Tag;
            Layer               = _object.Layer;
            BodyPart            = _object.BodyPart;
            UseBehaviourModeKey = _object.UseBehaviourModeKey;
            BehaviourModeKey    = _object.BehaviourModeKey;
            Influences          = _object.Influences;
        }
Пример #3
0
        public void HandleCollision(Collision collision)
        {
            if (!Environment.CollisionHandler.Enabled || Status.IsDead)
            {
                return;
            }

            CollisionDataObject _impact = Environment.CollisionHandler.CheckCollision(collision);

            if (_impact != null)
            {
                Status.AddDamage(_impact.Influences.Damage);
                Status.AddStress(_impact.Influences.Stress);
                Status.AddDebility(_impact.Influences.Debility);
                Status.AddHunger(_impact.Influences.Hunger);
                Status.AddThirst(_impact.Influences.Thirst);

                if (_impact.BehaviourModeKey != "")
                {
                    Behaviour.SetBehaviourModeByKey(_impact.BehaviourModeKey);
                }
            }
        }
 public CollisionDataObject(CollisionDataObject _object) : base(_object)
 {
     Copy(_object);
 }