public override void OnEvent(ObjectMoved evnt)
    {
        if (evnt.Entity.IsOwner)
        {
            // Interactive objects respond to events

            if (evnt.Entity.GetComponent <InteractiveObjects>())
            {
                i = evnt.Entity.GetComponent <InteractiveObjects>();
            }

            if (evnt.Push)
            {
                i.SetVelocity(evnt.Velocity);
                evnt.Entity.GetState <IDynamicObjectState>().Held = false;
            }
            else
            {
                if (evnt.Hold)
                {
                    i.Hold(evnt.Position, evnt.Rotation);
                    evnt.Entity.GetState <IDynamicObjectState>().Held = true;
                }
                else
                {
                    i.Drop(evnt.Velocity);
                    evnt.Entity.GetState <IDynamicObjectState>().Held = false;
                }
            }
        }
    }
Пример #2
0
        private void OnInteractiveObjectDestroyed(CoreInteractiveObject InteractiveObject)
        {
            InteractiveObjects.Remove(InteractiveObject);
            var interactiveObjectLogicCollider = InteractiveObject.InteractiveGameObject.GetLogicColliderAsBox();

            if (interactiveObjectLogicCollider != null)
            {
                InteractiveObjectsIndexedByLogicCollider.Remove(interactiveObjectLogicCollider);
            }
        }
Пример #3
0
        private void OnInteractiveObjectCreated(CoreInteractiveObject InteractiveObject)
        {
            InteractiveObjects.Add(InteractiveObject);
            var interactiveObjectLogicCollider = InteractiveObject.InteractiveGameObject.GetLogicColliderAsBox();

            if (interactiveObjectLogicCollider != null)
            {
                InteractiveObjectsIndexedByLogicCollider.Add(interactiveObjectLogicCollider, InteractiveObject);
            }
        }
Пример #4
0
        public override void OnDestroy()
        {
            base.OnDestroy();

            for (var i = InteractiveObjects.Count - 1; i >= 0; i--)
            {
                OnInteractiveObjectDestroyed(InteractiveObjects[i]);
            }

            InteractiveObjects.Clear();
            InteractiveObjects = null;
            InteractiveObjectsIndexedByLogicCollider.Clear();
            InteractiveObjectsIndexedByLogicCollider = null;
        }
Пример #5
0
        private void OnInteractiveObjectCreated(CoreInteractiveObject InteractiveObject)
        {
            InteractiveObjects.Add(InteractiveObject);
            if (InteractiveObject.InteractiveGameObject != null)
            {
                var interactiveObjectLogicCollider = InteractiveObject.InteractiveGameObject.LogicCollider;
                if (interactiveObjectLogicCollider != null)
                {
                    InteractiveObjectsIndexedByLogicCollider.Add(interactiveObjectLogicCollider, InteractiveObject);
                }
            }

            InteractiveObject.RegisterInteractiveObjectDestroyedEventListener(this.OnInteractiveObjectDestroyed);
        }
Пример #6
0
Файл: Map.cs Проект: jaoel/LD44
    private void DestroyAllInteractiveObjects()
    {
        InteractiveObjects.ForEach(x =>
        {
            GameObject.Destroy(x);
        });
        InteractiveObjects.Clear();

        Enemies.ForEach(x =>
        {
            GameObject.Destroy(x);
        });
        Enemies.Clear();
    }
Пример #7
0
Файл: Map.cs Проект: jaoel/LD44
 public void AddInteractiveObject(GameObject interactiveObject)
 {
     InteractiveObjects.Add(interactiveObject);
 }