Inheritance: MonoBehaviour
    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;
                }
            }
        }
    }
Example #2
0
        private void OnInteractiveObjectDestroyed(CoreInteractiveObject InteractiveObject)
        {
            InteractiveObjects.Remove(InteractiveObject);
            var interactiveObjectLogicCollider = InteractiveObject.InteractiveGameObject.GetLogicColliderAsBox();

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

            if (interactiveObjectLogicCollider != null)
            {
                InteractiveObjectsIndexedByLogicCollider.Add(interactiveObjectLogicCollider, InteractiveObject);
            }
        }
Example #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;
        }
Example #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);
        }
Example #6
0
File: Map.cs Project: jaoel/LD44
    private void DestroyAllInteractiveObjects()
    {
        InteractiveObjects.ForEach(x =>
        {
            GameObject.Destroy(x);
        });
        InteractiveObjects.Clear();

        Enemies.ForEach(x =>
        {
            GameObject.Destroy(x);
        });
        Enemies.Clear();
    }
Example #7
0
File: Map.cs Project: jaoel/LD44
 public void AddInteractiveObject(GameObject interactiveObject)
 {
     InteractiveObjects.Add(interactiveObject);
 }