Example #1
0
        private void EnterCollisionWithObject(EnterCollisionWithObjectMessage msg)
        {
            if (!_owner || msg.Object != _owner)
            {
                var apply = false;
                if (_requiredTraits.Count > 0)
                {
                    _traitCheckMsg.DoAfter = () =>
                    {
                        apply = true;
                    };
                    _controller.gameObject.SendMessageTo(_traitCheckMsg, msg.Object);
                }
                else
                {
                    apply = true;
                }
                if (apply)
                {
                    for (var i = 0; i < _applyToTargetOnEnter.Length; i++)
                    {
                        _addTraitToUnitMsg.Trait = _applyToTargetOnEnter[i];
                        _controller.gameObject.SendMessageTo(_addTraitToUnitMsg, msg.Object);
                    }

                    for (var i = 0; i < _applyToSelfOnEnter.Length; i++)
                    {
                        _addTraitToUnitMsg.Trait = _applyToSelfOnEnter[i];
                        _controller.gameObject.SendMessageTo(_addTraitToUnitMsg, _controller.transform.parent.gameObject);
                    }
                }
            }
        }
Example #2
0
        private void EnterCollisionWithObject(EnterCollisionWithObjectMessage msg)
        {
            var isPlayer = false;

            _playerCheckMsg.DoAfter = () =>
            {
                isPlayer = true;
            };
            _controller.gameObject.SendMessageTo(_playerCheckMsg, msg.Object);
            if (isPlayer)
            {
                _player = msg.Object;
            }
        }