Beispiel #1
0
        private void ActionWithObject(GameObject gameObject, GameObjectCollisionHandler wall)
        {
            var climber = gameObject.GetComponent <IClimber>();

            if (climber != null)
            {
                climber.Cling();
                AddItem(climber, wall);
            }
        }
Beispiel #2
0
        private void AddItem(IClimber climber, GameObjectCollisionHandler wall)
        {
            if (!_climbers.Contains(climber))
            {
                _climbers.Add(climber);
                climber.OnCanceledCling += CanceledCling;
                climber.OnDestroyed     += () => { _climbers.Remove(climber); };

                var direction = climber.transform.position - wall.transform.position;
                direction.y = 0;
                direction.z = 0;
                direction   = direction.normalized;
                climber.transform.rotation = Quaternion.LookRotation(direction);
            }
        }