public void MoveTo(ref GameObject From, ref GameObject To, bool AutoRemove) { From.AutoRemove = AutoRemove; FromMovement.Add(From); ToMovement.Add(To); MovementTween.Add(0); }
public TextureItem(Bitmap Img, GameObject.Type type) { img = Img; textureID = GameCore.CoreFiles.TextureIDs[type]; SizeX = img.Size.Width; SizeY = img.Size.Height; }
//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; }
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(); }
public void AddObjects(GameObject[] Objects) { for (int i = 0; i < Objects.Count(); i++) { Objects[i].OnDeath += new ObjectCollision(Player_OnDeath); gameObjects.Add(Objects[i]); } }
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(); } }
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); } }
public Bitmap getTexture(GameObject.Type type) { return LoadedTextures[type]; }
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; } }
void Player_OnDeath(GameObject obj) { gameObjects.Remove(obj); }
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(); }
void GameObject_OnCollision(GameObject obj) { }
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; }