示例#1
0
        public OrkForest(Vector2 position, Map map, Vector2 patrolTarget, NewTimer timer)
        {
            this.map = map;
            this.timer = timer;

            Tag = "OrkForest";

            transform = AddComponent<Transform>();
            transform.Position = position;

            renderer = AddComponent<ViewRenderer>();
            //renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/OrkForest/OrkForest_Front_0"));
            renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"), 32, 32);
            renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 1f);

            patrol = AddComponent<Patrol>();
            patrol.PatrolToTarget(patrolTarget);
            moveSpeed = 1;

            collider = AddComponent<BoxCollider>();
            collider.OnCollisionEnter += OnCollisionEnter;

            Animation = new SpriteAnimation(
               string.Empty,
            Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"),
               Path.Combine(Managers.Content.RootDirectory, "Sprites", "Sprite_Sheet", "RougyMon.xml"));
            Animation.FrameDelay = 100;

            EventManager.OnLateUpdate += OnLateUpdate;
            EventManager.OnUpdate += OnUpdate;
        }
示例#2
0
 public void CheckCollision(BoxCollider other)
 {
     if (bounds.Intersects(other.bounds))
     {
         if (!collisions.Contains(other))
         {
             collisions.Add(other);
             if (OnCollisionEnter != null)
                 OnCollisionEnter(other);
         }
         else
         {
             if (OnCollisionStay != null)
                 OnCollisionStay(other);
         }
     }
     else
     {
         BoxCollider exitCollider = collisions.Find((BoxCollider collider) => collider == other);
         if (exitCollider != null)
         {
             collisions.Remove(exitCollider);
             if (OnCollisionExit != null)
                 OnCollisionExit(other);
         }
     }
 }
示例#3
0
文件: Player.cs 项目: Xellss/RougyMon
        public Player(Vector2 position, Map map, DoorForest doorForest, GateGraveyard gateGraveyard)
        {
            this.gateGraveyard = gateGraveyard;
            this.doorForest = doorForest;
            this.map = map;

            Tag = "Player";

            transform = AddComponent<Transform>();
            transform.Position = position;

            renderer = AddComponent<ViewRenderer>();
            renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"), 32, 32);
            //renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 1f);
            renderer.Pivot = new Vector2(16, 32);

            moveWithInput = AddComponent<MoveWithInput>();
            moveWithInput.Speed = 5;
            moveWithInput.MoveWithArrow = OptionsMenuScreen.MoveArrows;

            collider = AddComponent<BoxCollider>();
            collider.OnCollisionEnter += OnCollisionEnter;

            Animation = new SpriteAnimation(
                string.Empty,
                Managers.Content.Load<Texture2D>("Sprites/Sprite_Sheet/RougyMon"),
                Path.Combine(Managers.Content.RootDirectory, "Sprites", "Sprite_Sheet", "RougyMon.xml"));
            Animation.FrameDelay = 100;

            EventManager.OnUpdate += OnUpdate;
            EventManager.OnLateUpdate += OnLateUpdate;
        }
示例#4
0
 private void OnCollisionEnter(BoxCollider other)
 {
     if (other.GameObject.Tag == "Player")
     {
         timer.Time = timer.Time.Add(new TimeSpan(0, 0, 20));
         Destroy();
     }
 }
示例#5
0
        private void OnCollisionEnter(BoxCollider other)
        {
            //if (other.GameObject.Tag == "Player")
            //{
            //    if (player.HasKey1)
            //        Destroy();
            //    else
            //    {
            //        Vector2 oldPlayerPosition = player.transform.Position;
            //        player.transform.Position = new Vector2(oldPlayerPosition.X, oldPlayerPosition.Y + 3);
            //    }

            //}
        }
示例#6
0
文件: Jewel.cs 项目: Xellss/RougyMon
        public Jewel(Vector2 position)
        {
            Tag = "Jewel";

            transform = AddComponent<Transform>();
            transform.Position = position;

            renderer = AddComponent<Renderer>();
            renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/Jewel"));
            renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 2f);

            collider = AddComponent<BoxCollider>();
            collider.OnCollisionEnter += OnCollisionEnter;
        }
示例#7
0
        public GateGraveyard(Vector2 position)
        {
            Tag = "GateGraveyard";

            transform = AddComponent<Transform>();
            transform.Position = position;

            renderer = AddComponent<Renderer>();
            renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/GateGraveyard"));
            //renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 2f);

            collider = AddComponent<BoxCollider>();

            EventManager.OnUpdate += OnUpdate;
        }
示例#8
0
        public DoorForest(Vector2 position)
        {
            Tag = "DoorForest";

            transform = AddComponent<Transform>();
            transform.Position = position;

            renderer = AddComponent<Renderer>();
            renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/DoorForest"));
            //renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 2f);

            collider = AddComponent<BoxCollider>();
            collider.OnCollisionEnter += OnCollisionEnter;

            EventManager.OnUpdate += OnUpdate;
        }
示例#9
0
        public HealPotion(Vector2 position, NewTimer timer)
        {
            Tag = "HealPotion";
            this.timer = timer;

            transform = AddComponent<Transform>();
            transform.Position = position;

            renderer = AddComponent<Renderer>();
            renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/Heal_Potion"));
            renderer.Pivot = new Vector2(renderer.ImageWidth / 2, renderer.ImageHeight / 2f);

            collider = AddComponent<BoxCollider>();
            collider.OnCollisionEnter += OnCollisionEnter;

            EventManager.OnUpdate += OnUpdate;
        }
示例#10
0
文件: Key.cs 项目: Xellss/RougyMon
 private void OnCollisionEnter(BoxCollider other)
 {
     if (other.GameObject.Tag == "Player")
         Destroy();
 }
示例#11
0
        void OnCollisionEnter(BoxCollider other)
        {
            if (other.GameObject.Tag == "Player")
            {
                if (Tag == "Jewel")
                {
                    Destroy();
                    ScreenManager.WinScreen = true;
                }
                timer.Time = timer.Time.Subtract(new TimeSpan(0, 0, 30));

                renderer.SetImage(Managers.Content.Load<Texture2D>("Sprites/Objects/Jewel"), 22, 32);
                transform.Position = new Vector2(transform.Position.X + 20, transform.Position.Y - 20);
                patrol.CanPatrol = false;
                renderer.Source = renderer.Image.Bounds;
                Tag = "Jewel";
            }
        }
示例#12
0
文件: Player.cs 项目: Xellss/RougyMon
        void OnCollisionEnter(BoxCollider other)
        {
            if (other.GameObject.Tag == "Key_1")
                HasKey1 = true;
            if (other.GameObject.Tag == "Key_2")
                HasKey2 = true;
            if (other.GameObject.Tag == "Jewel")
                HasJewel = true;
            if (other.GameObject.Tag == "Gold")
                GoldCounter++;
            if (other.GameObject.Tag == "DoorForest")
                if (HasKey1)
                    other.GameObject.Destroy();
            //else
            //    transform.Position = new Vector2(transform.Position.X, transform.Position.Y + 10);

            if (other.GameObject.Tag == "GateGraveyard")
                if (HasKey2)
                    other.GameObject.Destroy();
            //else
            //    transform.Position = new Vector2(transform.Position.X, transform.Position.Y + 10);
        }
示例#13
0
 public static void RemoveCollider(BoxCollider collider)
 {
     if (!removedColliders.Contains(collider))
         removedColliders.Add(collider);
 }
示例#14
0
 public static void AddCollider(BoxCollider collider)
 {
     if (!colliders.Contains(collider))
         colliders.Add(collider);
 }