public static bool DeleteObject(BaseGameObject obj) { if (data == null) { LoadData(); } if (obj == null || string.IsNullOrEmpty(obj.BaseObjectId) || string.IsNullOrEmpty(obj.BaseObjectName)) { return(false); } if (!data.ContainsKey(obj.BaseObjectId)) { return(false); } if (obj.CanHaveRefs) { //remove it from all cells List <BaseGameObject> allCells = WorldData.GetObjectsByType(typeof(Cell)); foreach (Cell c in allCells) { c.DeleteAllObjRefByBaseObjId(obj.BaseObjectId); } } return(data.Remove(obj.BaseObjectId)); }
public static IEnumerable <IGameObject> InitCollection() { list = new List <IGameObject>(); GridCreator.Grid = GridCreator.CreateGrid(PointCreator.CreatePoints()); var background = BaseGameObject.CreateStaticObject(AnimationType.MazeBlue, 0, 0); var tempList = PointCreator.CreatePoints().Select(GameObjectCreator.CreateOGameObject).Where(x => x != null).ToList(); var pac = tempList.OfType <Pacman>().First(); GrandArbiter grandArbiter = new GrandArbiter { Maze = (Background)background, Blinky = tempList.OfType <Blinky>().First() }; pac.Arbiter = grandArbiter; list.Add(background); list.AddRange(tempList); return(list); }
public override void Use(BaseGameObject useWithThis) { base.Use(useWithThis); //ToDo: Change this to a laughing buddha seed and plant. BasePot p = useWithThis as BasePot; p.PlantSeed(new PlantedSeedObject(this.Game, new BasePlant(this.Game, new Vector2(0, 0)), new Vector2(0, 0))); }
public void BaseGameObjectEventArgsConstructorTest1() { BaseGameObject gameObject = null; // TODO: 初始化为适当的值 BaseGameObjectEventArgs target = new BaseGameObjectEventArgs(gameObject); Assert.Inconclusive("TODO: 实现用来验证目标的代码"); }
public virtual void Use(BaseGameObject useWithThis) { if (!(useWithThis is BasePot)) { throw (new Exception("You can only use seeds with pots")); } }
public void BaseGameObjectConstructorTest2() { Serial serial = new Serial(); // TODO: 初始化为适当的值 BaseGameObject target = new BaseGameObject(serial); Assert.Inconclusive("TODO: 实现用来验证目标的代码"); }
public virtual void Use(BaseGameObject useWithThis) { if (!(useWithThis is BasePot) && !(useWithThis is BaseWaterSource)) { throw (new Exception("You can only use watering tools with pots or watering sources.")); } }
private static bool DoesRayInterestMesh(BaseGameObject gm, Vector3 orig, Vector3 dir) { Model model = gm as Model; Vector3[] verts = model.Mesh3d.GetMeshVertices(); int[] indices = model.Mesh3d.GetMeshIndices(); int dwNumFaces = model.MeshObj.FaceCount; for (int i = 0; i < dwNumFaces; i++) { int i0 = indices[3 * i + 0]; int i1 = indices[3 * i + 1]; int i2 = indices[3 * i + 2]; Vector3 v0 = verts[i0]; Vector3 v1 = verts[i1]; Vector3 v2 = verts[i2]; //// Check if the pick ray passes through this point if (IntersectTriangle(orig, dir, v0, v1, v2)) { return(true); } } return(false); }
private void objectsGrid_MouseMove(object sender, MouseEventArgs e) { // Get the current mouse position Point mousePos = e.GetPosition(null); Vector diff = startPoint - mousePos; if (e.LeftButton == MouseButtonState.Pressed && (Math.Abs(diff.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(diff.Y) > SystemParameters.MinimumVerticalDragDistance)) { if (objectsGrid.SelectedItem == null) { return; } BaseGameObject obj = (BaseGameObject)objectsGrid.SelectedItem; if (obj == null) { return; } DataGridRow container = (DataGridRow)objectsGrid.ItemContainerGenerator.ContainerFromItem(objectsGrid.SelectedItem); DataObject dataObj = new DataObject("GameObjectReference", obj); DragDrop.DoDragDrop(container, dataObj, DragDropEffects.Move); } }
private string ReadObject(BaseGameObject obj) { if (obj != null && IsMinimized) { switch (obj) { case Mobile mob: return ($"Mobile (0x{mob.Serial:X8}) graphic: 0x{mob.Graphic:X4} flags: {mob.Flags} noto: {mob.NotorietyFlag}"); case Item item: return ($"Item (0x{item.Serial:X8}) graphic: 0x{item.Graphic:X4} flags: {item.Flags} amount: {item.Amount} itemdata: {item.ItemData.Flags}"); case Static st: return ($"Static (0x{st.Graphic:X4}) height: {st.ItemData.Height} flags: {st.ItemData.Flags} Alpha: {st.AlphaHue}"); case Multi multi: return ($"Multi (0x{multi.Graphic:X4}) height: {multi.ItemData.Height} flags: {multi.ItemData.Flags}"); case GameEffect effect: return("GameEffect"); case TextObject overhead: return($"TextOverhead type: {overhead.Type} hue: 0x{overhead.Hue:X4}"); case Land land: return($"Land (0x{land.Graphic:X4}) flags: {land.TileData.Flags}"); } } return(string.Empty); }
public virtual void Draw(UltimaBatcher2D batcher, int startX, int startY, int renderIndex, bool isGump = false) { ProcessWorldText(false); int mouseX = Mouse.Position.X; int mouseY = Mouse.Position.Y; BaseGameObject last = SelectedObject.LastObject; for (TextObject o = _drawPointer; o != null; o = o.DLeft) { if (o.IsDestroyed || o.RenderedText == null || o.RenderedText.IsDestroyed || o.RenderedText.Texture == null || o.Time < ClassicUO.Time.Ticks || o.Owner.UseInRender != renderIndex && !isGump) { continue; } ushort hue = 0; float alpha = 1f - o.Alpha / 255f; if (o.IsTransparent) { if (o.Alpha == 0xFF) { alpha = 1f - 0x7F / 255f; } } int x = o.RealScreenPosition.X; int y = o.RealScreenPosition.Y; if (o.RenderedText.Texture.Contains(mouseX - x - startX, mouseY - y - startY)) { if (isGump) { SelectedObject.LastObject = o; } else { SelectedObject.Object = o; } } if (!isGump) { if (o.Owner is Entity && last == o) { hue = 0x0035; } } else { x += startX; y += startY; } o.RenderedText.Draw(batcher, x, y, alpha, hue); } }
public override void Contact(BaseGameObject Object) { if (Object.Fraction != fraction) { Object.AddedDamage(damage, DamageTypes.Energy); } Destroy(gameObject); }
private bool IsObjectInView(BaseGameObject obj) { if (obj.BoundingBox == null) { return(true); // Otherwise, objects without bounding box can never be drawn! } return(IsObjectInArea(obj.BoundingBox.FullRectangle)); }
protected BaseComponent(BaseGameObject owner) { Owner = owner; if (!CheckDependComponents()) { throw new ApplicationException("No linked component"); } }
public override void FeedbackTo( BaseGameObject other ) { if (other is GameUnit) { var gu = (other as GameUnit); gu.Attack = gu.Attack + Attack; gu.Deffence = gu.Deffence + Defence; } }
public void OnUpdatedNameTest1() { BaseGameObjectState target = new BaseGameObjectState(); // TODO: 初始化为适当的值 string strName = string.Empty; // TODO: 初始化为适当的值 BaseGameObject creature = null; // TODO: 初始化为适当的值 target.OnUpdatedName(strName, creature); Assert.Inconclusive("无法验证不返回值的方法。"); }
private void objectsGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { BaseGameObject selectedItem = (BaseGameObject)objectsGrid.SelectedItem; if (selectedItem != null) { objectsGrid.ContextMenu = objectsGrid.Resources["deleteContext"] as System.Windows.Controls.ContextMenu; } }
public void GameObjectTest1() { BaseGameObject gameObject = null; // TODO: 初始化为适当的值 BaseGameObjectEventArgs target = new BaseGameObjectEventArgs(gameObject); // TODO: 初始化为适当的值 BaseGameObject actual; actual = target.GameObject; Assert.Inconclusive("验证此测试方法的正确性。"); }
public override void CooperateWith(BaseGameObject other) { base.CooperateWith(other); if (other is GameUnit) { var gu = other as GameUnit; gu.Deffence = gu.Deffence - Attack; } }
public override void FeedbackTo(BaseGameObject other) { base.FeedbackTo(other); if ( other is GameUnit) { var gu = other as GameUnit; gu.Deffence = gu.Deffence - Attack; } }
public void NameTest() { BaseGameObject target = new BaseGameObject(); // TODO: 初始化为适当的值 string expected = string.Empty; // TODO: 初始化为适当的值 string actual; target.Name = expected; actual = target.Name; Assert.AreEqual( expected, actual ); Assert.Inconclusive( "验证此测试方法的正确性。" ); }
private void OnCollisionEnter2D(Collision2D collision) { BaseGameObject tmpObj = collision.gameObject.GetComponent <BaseGameObject>(); // Check if the beam is the owner's, if not owner's, take damage if (tmpObj.GameObjectOwner != this.GetComponent <BaseGameObject>().GameObjectOwner) { // Take damage } }
public void ToStringTest() { BaseGameObject target = new BaseGameObject(); // TODO: 初始化为适当的值 string expected = string.Empty; // TODO: 初始化为适当的值 string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public void CreateNewGameObjectInstanceTest1() { BaseGameObject target = new BaseGameObject(); // TODO: 初始化为适当的值 BaseGameObject expected = null; // TODO: 初始化为适当的值 BaseGameObject actual; actual = target.CreateNewGameObjectInstance(); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public static void TargetGameObject(BaseGameObject selectedEntity) { if (selectedEntity == null || !IsTargeting) { return; } if (selectedEntity is GameEffect effect && effect.Source != null) { selectedEntity = effect.Source; }
void GetAnotherGoal() { foreach (BaseGameObject G in agroList) { if (G != currentTarget) { currentTarget = G; return; } } }
public void CompareToTest1() { BaseGameObject target = new BaseGameObject(); // TODO: 初始化为适当的值 BaseGameObject other = null; // TODO: 初始化为适当的值 int expected = 0; // TODO: 初始化为适当的值 int actual; actual = target.CompareTo(other); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public override void Use(BaseGameObject useWithThis) { base.Use(useWithThis); BaseWateringTool t = useWithThis as BaseWateringTool; if (t != null) { t.PH += this.Ph; t.WaterQuality += this.NutritionValue; } }
public void OnUpdatingNameTest() { BaseGameObjectState target = new BaseGameObjectState(); // TODO: 初始化为适当的值 string strName = string.Empty; // TODO: 初始化为适当的值 BaseGameObject creature = null; // TODO: 初始化为适当的值 bool expected = false; // TODO: 初始化为适当的值 bool actual; actual = target.OnUpdatingName(strName, creature); Assert.AreEqual(expected, actual); Assert.Inconclusive("验证此测试方法的正确性。"); }
public override void Contact(BaseGameObject Object) { Vector2 deltaVlocity = Rigidbodies[0].velocity - Object.Rigidbodies[0].GetVector(Rigidbodies[0].transform.up); float ContactForce = deltaVlocity.magnitude * Rigidbodies[0].mass; Object.Rigidbodies[0].AddForce(Rigidbodies[0].transform.up * ContactForce, ForceMode2D.Impulse); if (Object.Fraction != fraction) { Object.AddedDamage(ContactForce * armorPiercing, DamageTypes.Kinetic); } Destroy(gameObject); }
public static BaseGameObject CreateOGameObject(PointData point) { BaseGameObject res = null; switch (point.InitData) { case InitialData.Pacman: res = new Pacman(); res.Animation.Location = point.Crdnt; res.Name = InitialData.Pacman.ToString(); break; case InitialData.Blinky: res = new Blinky(); res.Animation.Location = point.Crdnt; res.Name = InitialData.Blinky.ToString(); break; /*case InitialData.Inky: * res = new Inky(); * res.Animation.Location = point.Crdnt; * res.Name = InitialData.Inky.ToString(); * break; * * case InitialData.Pinky: * res = new Pinky(); * res.Animation.Location = point.Crdnt; * res.Name = InitialData.Pinky.ToString(); * break; * * case InitialData.Clyde: * res = new Clyde(); * res.Animation.Location = point.Crdnt; * res.Name = InitialData.Clyde.ToString(); * break;*/ case InitialData.BigCoin: res = new BigCoin(); res.Animation.Location = point.Crdnt; res.Name = InitialData.BigCoin.ToString(); break; case InitialData.SmallCoin: res = new SmallCoin(); res.Animation.Location = point.Crdnt; res.Name = InitialData.SmallCoin.ToString(); break; } return(res); }
private void HandleCollision(BaseGameObject hitBy, BaseGameObject hitObject) { // only allow hitting objects if the projectile is still on the screen. Otherwise we can // destroy turrets before they show up if (hitBy is IGameObjectWithDamage && hitBy.Position.Y >= 0) { var projectile = (IGameObjectWithDamage)hitBy; var hitEvent = new GameplayEvents.ObjectHitBy(projectile); hitObject.OnNotify(hitEvent); _soundManager.OnNotify(hitEvent); } }
private void MenuItem_DeleteClick(object sender, RoutedEventArgs e) { BaseGameObject obj = (BaseGameObject)objectsGrid.SelectedItem; if (obj == null) { return; } WorldData.DeleteObject(obj); Refresh(); }
public static Dictionary <string, BaseRenderObject> GetDebugRenderObjects(BaseGameObject o) { var mDic = new Dictionary <string, BaseRenderObject>(); var p = new DynamicTextBlock(0, -15, () => "Pos: " + o.Position) { Debug = true }; mDic.Add("position_text", p); return(mDic); }
public override void PerformInteraction(Board board, BoardBot bot, Direction direction) { BaseGameObject targetTeleporter = board.GameObjects.Where(gf => gf is Teleporter && (gf as Teleporter).LinkedTeleporterString == this.LinkedTeleporterString && !this.Position.Equals(gf.Position)).FirstOrDefault(); if (targetTeleporter == null) { return; } if (targetTeleporter != null && !board.IsPositionBlocked(targetTeleporter.Position)) { bot.Position = targetTeleporter.Position; } }
void statefulFont_StateChanged(object sender, StateEventArgs e) { if (e.DataType == typeof(DropInFont.FontState)) { if ((DropInFont.FontState)e.Data == DropInFont.FontState.Compress) { crashEffect.Play(); } BaseGameObject gameObject = (BaseGameObject)sender; if (gameObject.Tag != null && (GameTags)gameObject.Tag == GameTags.StartTitleFadeIn) { titleText2.Fade = true; } } }
void OnTriggerEnter2D(Collider2D collider) { if (collider.isTrigger) { return; } BaseGameObject contactObject = collider.GetComponent <BaseGameObject>(); if (contactObject == null && collider.attachedRigidbody != null) { contactObject = collider.attachedRigidbody.GetComponent <BaseGameObject> (); } if (contactObject != null && contactObject.ID != parentInstanceID) { Contact(contactObject); } }
public void ContinuousRandomSlerpTest() { //Given GameTimer constantTimer = new ConstantTimer(new TimeSpan(0, 0, 0, 0, 33)); BaseGameObject testObject = new BaseGameObject("OrbitTestObject"); ContinuousRandomSlerp component = new ContinuousRandomSlerp(testObject.Transform, 0.25f); //When for (int update = 0; update < 300; update++) { component.Update(constantTimer); } //Then Assert.IsTrue(testObject.Transform.Rotation.Length() > 0.0f); }
public override void Use(BaseGameObject useWithThis) { base.Use(useWithThis); //Check to see what type of object it is the lazy way, if it's null it's not a pot. BasePot p = useWithThis as BasePot; if (p != null) { p.Water(0.01); this.RemainingWater -= 0.1; return; } BaseWaterSource s = useWithThis as BaseWaterSource; if (s != null) { this.RemainingWater = 1.0; this.WaterQuality = s.Quality; } }
public virtual void CooperateWith(BaseGameObject other) { }
/// <summary> /// 初始化构造 /// </summary> /// <param name="baseCreature"></param> public BaseGameObjectEventArgs( BaseGameObject gameObject ) { m_GameObject = gameObject; }
public override void Use(BaseGameObject useWithThis) { base.Use(useWithThis); }
//public virtual void Use(BaseGameObject useWithThis) //{ //} public virtual void Use(BaseGameObject useWithThis) { throw new System.NotImplementedException(); }
/// <summary> /// 初始化构造 /// </summary> /// <param name="baseCreature"></param> public UpdatingNameEventArgs( string strName, BaseGameObject creature ) : base( creature ) { m_NewName = strName; }
/// <summary> /// /// </summary> internal void OnUpdatedName( string strName, BaseGameObject creature ) { EventHandler<UpdatedNameEventArgs> tempAfterEventArgs = m_EventUpdatedName; if ( tempAfterEventArgs != null ) { UpdatedNameEventArgs eventArgs = new UpdatedNameEventArgs( strName, creature ); tempAfterEventArgs( this, eventArgs ); } }
public void BaseGameObjectConstructorTest3() { BaseGameObject target = new BaseGameObject(); Assert.Inconclusive( "TODO: 实现用来验证目标的代码" ); }
public override void Use(BaseGameObject useWithThis) { base.Use(useWithThis); BasePot p = useWithThis as BasePot; p.AddGrowMedium(new PHBalancedSoil(this.Game, new Vector2(0,0))); }
public void CompareToTest1() { BaseGameObject target = new BaseGameObject(); // TODO: 初始化为适当的值 BaseGameObject other = null; // TODO: 初始化为适当的值 int expected = 0; // TODO: 初始化为适当的值 int actual; actual = target.CompareTo( other ); Assert.AreEqual( expected, actual ); Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public virtual void Use(BaseGameObject useWithThis) { //ToDo: Make it so that lights can only be used with the cabinet, or grow slot, or whatever. }
public override void Use(BaseGameObject useWithThis) { base.Use(useWithThis); BasePot p = useWithThis as BasePot; p.AddGrowMedium(new HydroponicMedium(this.Game, new Vector2(0,0))); }
public void CreateNewGameObjectInstanceTest1() { BaseGameObject target = new BaseGameObject(); // TODO: 初始化为适当的值 BaseGameObject expected = null; // TODO: 初始化为适当的值 BaseGameObject actual; actual = target.CreateNewGameObjectInstance(); Assert.AreEqual( expected, actual ); Assert.Inconclusive( "验证此测试方法的正确性。" ); }
public virtual void FeedbackTo(BaseGameObject other ) { }
public override void Use(BaseGameObject useWithThis) { base.Use(useWithThis); BasePot p = useWithThis as BasePot; p.PlantSeed(new PlantedWaterMelonSeed(this.Game, new WaterMelonPlant(this.Game, new Vector2(0,0)), new Vector2(0,0))); }
/// <summary> /// /// </summary> internal bool OnUpdatingName( string strName, BaseGameObject creature ) { EventHandler<UpdatingNameEventArgs> tempBeforeEventArgs = m_EventUpdatingName; if ( tempBeforeEventArgs != null ) { UpdatingNameEventArgs eventArgs = new UpdatingNameEventArgs( strName, creature ); tempBeforeEventArgs( this, eventArgs ); return eventArgs.IsCancel; } return false; }
public void BaseGameObjectConstructorTest2() { Serial serial = new Serial(); // TODO: 初始化为适当的值 BaseGameObject target = new BaseGameObject( serial ); Assert.Inconclusive( "TODO: 实现用来验证目标的代码" ); }