예제 #1
0
 public void MoveTo(ref GameObject From, ref GameObject To, bool AutoRemove)
 {
     From.AutoRemove = AutoRemove;
     FromMovement.Add(From);
     ToMovement.Add(To);
     MovementTween.Add(0);
 }
예제 #2
0
 public TextureItem(Bitmap Img, GameObject.Type type)
 {
     img = Img;
     textureID = GameCore.CoreFiles.TextureIDs[type];
     SizeX = img.Size.Width;
     SizeY = img.Size.Height;
 }
예제 #3
0
 //public int[] GetDifference(int x1, int y1, int x2, int y2)
 //{
 //}
 public bool IsAttacking(ref GameObject FromObj)
 {
     if (FromMovement.Contains(FromObj))
         return true;
     else
         return false;
 }
예제 #4
0
        public GameObject[] GenerateStartGame(int TeamNumber, int BaseX, int BaseY)
        {
            List<GameObject> objects = new List<GameObject>();
            GameObject House = new GameObject(GameObject.Type.House);
            GameObject Barn = new GameObject(GameObject.Type.Barn);
            GameObject Footman = new GameObject(GameObject.Type.Footman);
            GameObject Footman1 = new GameObject(GameObject.Type.Footman);
            GameObject Footman2 = new GameObject(GameObject.Type.Footman);
            House.X = BaseX + 0;
            House.Y = BaseY + 0;
            Barn.X = BaseX + 0;
            Barn.Y = BaseY + TextureItem.RatioSize * 1;
            Footman.X = BaseX + TextureItem.RatioSize * 1;
            Footman.Y = BaseY + 0;
            Footman1.X = BaseX + TextureItem.RatioSize * 1;
            Footman1.Y = BaseY + TextureItem.RatioSize * 1;
            Footman2.X = BaseX + TextureItem.RatioSize * 2;
            Footman2.Y = BaseY + 0;

            objects.Add(House);
            objects.Add(Barn);
            objects.Add(Footman);
            objects.Add(Footman1);
            objects.Add(Footman2);
            foreach (GameObject gameObj in objects)
                gameObj.TeamNumber = TeamNumber;

            return objects.ToArray();
        }
예제 #5
0
파일: Player.cs 프로젝트: Geramy/TFAGame
 public void AddObjects(GameObject[] Objects)
 {
     for (int i = 0; i < Objects.Count(); i++)
     {
         Objects[i].OnDeath += new ObjectCollision(Player_OnDeath);
         gameObjects.Add(Objects[i]);
     }
 }
예제 #6
0
파일: GameLogic.cs 프로젝트: Geramy/TFAGame
 public static void AttackItem(GameObject From, GameObject To)
 {
     if (From.Damage > 0)
     {
         if (To.Health > 0)
             To.Health -= From.Damage * From.Level;
         else if(To.ObjType != GameObject.Type.Grass)
             To.DeleteSelf();
     }
 }
예제 #7
0
 public void StopAttacking(ref GameObject FromObj)
 {
     int pos = -1;
     int i = 0;
     lock (FromMovement)
     {
         foreach (GameObject Obj in FromMovement)
         {
             if (Obj == FromObj)
             {
                 pos = i;
                 break;
             }
             i++;
         }
     }
     if (pos != -1)
     {
         FromMovement[pos].AutoRemove = false;
         FromMovement.RemoveAt(pos);
         ToMovement.RemoveAt(pos);
         MovementTween.RemoveAt(pos);
     }
 }
예제 #8
0
파일: Memory.cs 프로젝트: Geramy/TFAGame
 public Bitmap getTexture(GameObject.Type type)
 {
     return LoadedTextures[type];
 }
예제 #9
0
파일: GameCore.cs 프로젝트: Geramy/TFAGame
 public static void MouseDown(int x, int y)
 {
     if (CurrentItem == null)
     {
         for (int i = 0; i < players.Keys.Count; i++)
             CurrentItem = players[players.Keys.ToArray()[i]].GetObject(x, y, true);
         if (CurrentItem != null && !CurrentItem.Moveable)
             CurrentItem = null;
     }
     else
     {
         GameObject secondItem = null;
         for (int i = 0; i < players.Keys.Count; i++)
         {
             secondItem = players[players.Keys.ToArray()[i]].GetObject(x, y);
             if (secondItem != null)
                 break;
         }
         if (secondItem == null)
         {
             for (int i = 0; i < GameCore.GrassPatches.Length; i++)
                 if (GameCore.GrassPatches[i].MouseIsOver(x, y))
                     secondItem = GameCore.GrassPatches[i];
         }
         if (GameCore.PhysX.IsAttacking(ref CurrentItem))
         {
             GameCore.PhysX.StopAttacking(ref CurrentItem);
         }
         if(secondItem == null)
             PhysX.MoveTo(ref CurrentItem, ref secondItem, false);
         else
             PhysX.MoveTo(ref CurrentItem, ref secondItem, true);
         CurrentItem = null;
     }
 }
예제 #10
0
파일: Player.cs 프로젝트: Geramy/TFAGame
 void Player_OnDeath(GameObject obj)
 {
     gameObjects.Remove(obj);
 }
예제 #11
0
파일: Form1.cs 프로젝트: Geramy/TFAGame
        private void GLScreen_Load(object sender, EventArgs e)
        {
            bOpenGLReady = true;
            SetupViewport();

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.Disable(EnableCap.DepthTest);
            GameCore.CoreFiles = new Memory();

            GameObject Grass = new GameObject(GameObject.Type.Grass);
            int MaxX = Size.Width / TextureItem.RatioSize;
            int MaxY = Size.Height / TextureItem.RatioSize;
            GameCore.GrassPatches = new GameObject[MaxX * MaxY];
            int i = 0;
            for (int x = 0; x < MaxX; x++)
            {
                for (int y = 0; y < MaxY; y++)
                {
                    GameCore.GrassPatches[i] = new GameObject(GameObject.Type.Grass);
                    GameCore.GrassPatches[i].X = x * TextureItem.RatioSize;
                    GameCore.GrassPatches[i].Y = y * TextureItem.RatioSize;
                    i++;
                }
            }
            GameCore.SetupModules();
        }
예제 #12
0
 void GameObject_OnCollision(GameObject obj)
 {
 }
예제 #13
0
 public bool IsBumping(GameObject to)
 {
     if (to == null)
         return false;
     //X obj1 From
     //x Obj2 To
     Rectangle From = new Rectangle(X, Y, TextureItem.RatioSize, TextureItem.RatioSize);
     Rectangle To = new Rectangle(to.X, to.Y, TextureItem.RatioSize, TextureItem.RatioSize);
     if (From.IntersectsWith(To))
         return true;
     else
         return false;
 }