示例#1
0
        private void InteractHnadler(Gameplay.InteractComponent interactComponent, Core.GameObject interacting)
        {
            Core.Transform newTransofrm = new Core.Transform(transform);
            newTransofrm.position.X += 100;
            newTransofrm.position.Y += 100;
            Banana newBanana = new Banana(newTransofrm);

            Core.GameManager.SpawnObject(newBanana);
        }
示例#2
0
        private void Interact()
        {
            List <Core.GameObject> inRange = Parent.GetComponent <Physics.Collider.Collider>().GetOverlapingObjects();

            foreach (var colliding in inRange)
            {
                Gameplay.InteractComponent interactComponent = colliding.GetComponent <Gameplay.InteractComponent>();
                if (interactComponent == null)
                {
                    continue;
                }

                interactComponent.Interact(Parent);
            }
        }
示例#3
0
        private void Load(Core.Transform _transform)
        {
            // Physics
            collider = AddComponent(new CircleCollider(this, CollisionChanell.Item, Vector2.Zero, size / 2));
            collider.OnBeginOverlap += CheckCollision;

            interactComponent             = AddComponent(new Gameplay.InteractComponent(this));
            interactComponent.OnInteract += InteractHnadler;

            List <Rectangle> idle01 = new List <Rectangle>();

            for (int i = 0; i < height; ++i)
            {
                idle01.Add(new Rectangle(i * size, 0, size, size));
            }
            AddComponent(new Graphics.Sprite(this, "banana", idle01));

            AddComponent(new Graphics.StackAnimator(this));

            List <Rectangle> idle02 = new List <Rectangle>();

            for (int i = 0; i < height; ++i)
            {
                idle02.Add(new Rectangle(i * size, size, size, size));
            }
            List <Rectangle> idle03 = new List <Rectangle>();

            for (int i = 0; i < height; ++i)
            {
                idle03.Add(new Rectangle(i * size, size * 2, size, size));
            }
            GetComponent <Graphics.StackAnimator>().AddAnimation(
                new Graphics.StackAnimation("Idle",
                                            GetComponent <Graphics.Sprite>(),
                                            new List <List <Rectangle> > {
                idle01, idle02, idle03, idle02
            },
                                            266,
                                            true));

            GetComponent <Graphics.StackAnimator>().SetAnimation("Idle");
        }