/// <summary> /// Changes the state of the entity and notifies the system that the property changed /// </summary> /// <param name="newEntityState">New entity state</param> /// <param name="propertyName">Name of the changed property</param> /// <remarks></remarks> protected internal void SetEntityState(EntityStateType newEntityState, string propertyName) { SetEntityState(newEntityState); if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } }
public void Destroy(bool destroyView = true) { if (halfDestroyEffectId > 0) { GameEffectManager.Instance.RemoveEffect(halfDestroyEffectId); } this.State = EntityStateType.Dead; foreach (var entityComponent in components) { entityComponent.Destroy(); } if (view != null && destroyView) { GameObject.Destroy(view.gameObject); view = null; } }
public void Draw(bool drawForced) { this.ReCalculateBody(); if (this.state == EntityStateType.HalfDestroyed) { this.state = EntityStateType.Destroyed; } else if (this.state == EntityStateType.Destroyed) { this.state = EntityStateType.Disappeared; } else if (this.state == EntityStateType.Disappeared) { this.IsDestroyed = true; } // borders of rectangle which includes body in previous and new position int left = Math.Min(this.Field.PlayWidth - 1, Math.Max(0, Math.Min(this.previousLeft, this.Body.Select(pixel => pixel.Coordinate.X).Min()))); int top = Math.Min(this.Field.PlayHeight - 1, Math.Max(0, Math.Min(this.previousTop, this.Body.Select(pixel => pixel.Coordinate.Y).Min()))); int right = Math.Max(0, Math.Min(this.Field.PlayWidth - 1, Math.Max(this.previousRight, this.Body.Select(pixel => pixel.Coordinate.X).Max()))); int bottom = Math.Max(0, Math.Min(this.Field.PlayHeight - 1, Math.Max(this.previousBottom, this.Body.Select(pixel => pixel.Coordinate.Y).Max()))); this.previousLeft = left; this.previousTop = top; this.previousRight = right; this.previousBottom = bottom; foreach (Pixel pixel in this.Body) { if (!(pixel.Coordinate.X < 0 || pixel.Coordinate.X >= this.Field.PlayWidth || pixel.Coordinate.Y < 0 || pixel.Coordinate.Y >= this.Field.PlayHeight)) { pixel.Draw(); } } // Avoids screen flickering: draw rectangle which includes body in previous and new position if (drawForced) { ScreenBuffer.DrawRectangle(left, top, right, bottom); } }
protected internal void SetEntityState(EntityStateType newEntityState) { switch (newEntityState) { case EntityStateType.Deleted: case EntityStateType.Unchanged: case EntityStateType.Added: this.m_EntityState = newEntityState; break; default: if (this.EntityState == EntityStateType.Unchanged) { this.m_EntityState = newEntityState; } break; } }
private void UpdateDestroy(float dt) { // 死亡了 但尚未置于死亡状态(则释放) if (currentHp <= 0 && this.State != EntityStateType.Dead) { this.State = EntityStateType.Dead; if (GameWorld.Instance.worldType == WorldType.Battle || GameWorld.Instance.worldType == WorldType.Replay) { BattleManager.Instance.OnEntityDestroy(this); } //创建战斗时被销毁的残渣 if (EntityTypeUtil.IsAnyBuilding(entityType)) { GameObject.Destroy(view.body.gameObject); GameObject.Destroy(view.hpBar.gameObject); if (view.shadow != null) { GameObject.Destroy(view.shadow.gameObject); } GameEffectManager.Instance.AddEffect("Phouse_die", GetRenderPosition());//TODO var destroyView = (GameObject)ResourceManager.Instance.LoadAndCreate("Misc/DestroyedBuildingView"); view.AddSubView(destroyView, Vector3.zero); IsoHelper.FaceToWorldCamera(destroyView.transform); IsoHelper.MoveAlongCamera(destroyView.transform, 19); Destroy(false); IsoMap.Instance.RemoveBuildingMapData(this);//移除占地数据,对象还是在IsoMap中 } else if (EntityTypeUtil.IsAnyActor(entityType)) { GameEffectManager.Instance.AddEffect("Psoldier_die", GetRenderPosition()); IsoMap.Instance.DelayRemoveEntity(this); Destroy(); } else { IsoMap.Instance.DelayRemoveEntity(this); Destroy(); } } }
/// <summary> /// Changes the state of the entity /// </summary> /// <param name="newEntityState">New entity state</param> /// <remarks></remarks> protected internal void SetEntityState(EntityStateType newEntityState) { switch (newEntityState) { case EntityStateType.Deleted: case EntityStateType.Unchanged: case EntityStateType.Added: // If the new state is deleted, mark it as deleted // If the new state is unchanged, mark it as unchanged // If the new state is added, mark it as added this.EntityState = newEntityState; break; default: // Only set other data states if the existing state is unchanged if (this.EntityState == EntityStateType.Unchanged) { this.EntityState = newEntityState; } break; } }
public PavewayBomb(Field field, Point2D position, EntityStateType entityState) : this(field, position, PavewayBomb.BodyStates(), entityState) { }
public SimplePanelka(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { }
public BadShooterEnemy(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { // you can override here initial bomb movement direction values set in base constructor this.DeltaX = -1; this.DeltaY = -0.5M; this.randomPositionToStopMovementOnXAxis = RandomProvider.Instance.Next(this.Field.PlayWidth / 4, this.Field.PlayWidth - (this.Field.PlayWidth / 4)); this.IsShootingEnabled = true; }
protected Fighter(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { this.Name = Constants.NameNotSet; this.bullets = new List <Bullet>(); this.bombs = new List <Bomb>(); this.missiles = new List <Missile>(); this.moveDirection = MoveDirectionType.OnHold; ConsoleKeyboardHandler.Instance.KeyDown += this.Instance_KeyDown; }
public void SetUnchanged() { m_EntityState = EntityStateType.Unchanged; }
public void SetAdded() { m_EntityState = EntityStateType.Added; }
/// <summary> /// Changes the state of the entity and notifies the system that the property changed /// </summary> /// <param name="newEntityState">New entity state</param> /// <param name="propertyName">Name of the changed property</param> /// <remarks></remarks> protected internal void SetEntityState(EntityStateType newEntityState, string propertyName) { SetEntityState(newEntityState); if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); }
public ShootingTower(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { }
public ShootingTower(Field field, Point2D position, EntityStateType entityState) : this(field, position, ShootingTower.BodyStates(), entityState) { }
protected Bomb(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { // defines initial bomb movement direction values this.DeltaX = 0.75M; this.DeltaY = 1.0M; this.BombPositionX = position.X; this.BombPositionY = position.Y; }
/// <summary> /// Changes the set of the entity to modified or new depending on the flag /// </summary> /// <param name="isNew">True to set the state to New</param> /// <remarks> /// This is a simplified public method for use by RIA for Silverlight. /// </remarks> public void SetEntityState(bool isNew) { if (isNew) { this.EntityState = EntityStateType.Added; } else { this.EntityState = EntityStateType.Modified; } }
public void SetDeleted() { m_EntityState = EntityStateType.Deleted; }
public PavewayBomb(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { // decimal g = 2M; this.DeltaX = 0.7M; this.DeltaY = 1.0M; }
public Entity(Field field, Point2D position, IList <IList <Pixel> > relativeBodyStates, EntityStateType state) { this.Field = field; this.Position = position; this.relativeBodyStates = relativeBodyStates; this.State = (int)state; // TODO: refactor to not use 2 lists (very difficult task) //this.Body = relativeBodyStates[this.State] // .ConvertAll(pixel => new Pixel(pixel.Coordinate.X, pixel.Coordinate.Y, pixel.Symbol, pixel.Color)); this.Body = new List <Pixel>(relativeBodyStates[this.State].Count); for (int i = 0; i < relativeBodyStates[this.State].Count; i++) { //Pixel pixel = relativeBodyStates[this.State][i]; this.Body.Add(new Pixel(relativeBodyStates[this.State][i].Coordinate.X, relativeBodyStates[this.State][i].Coordinate.Y, relativeBodyStates[this.State][i].Symbol, relativeBodyStates[this.State][i].Color)); } this.CalculateWidthAndHeightOfEntityBody(); this.ReCalculateBody(); this.previousLeft = 0; this.previousTop = 0; this.previousRight = field.PlayWidth - 1; this.previousBottom = field.PlayHeight - 1; }
public virtual void HandleStateChange(EntityStateType oldState, EntityStateType nowState) { }
/// <summary> /// Changes the state of the entity /// </summary> /// <param name="newEntityState">New entity state</param> /// <remarks></remarks> protected internal void SetEntityState(EntityStateType newEntityState) { switch (newEntityState) { case EntityStateType.Deleted: case EntityStateType.Unchanged: case EntityStateType.Added: // If the new state is deleted, mark it as deleted // If the new state is unchanged, mark it as unchanged // If the new state is added, mark it as added this.EntityState = newEntityState; break; default: // Only set other data states if the existing state is unchanged if (this.EntityState == EntityStateType.Unchanged) this.EntityState = newEntityState; break; } }
public void SetModified() { m_EntityState = EntityStateType.Modified; }
public CrazyCrawlEnemy(Field field, Point2D position, EntityStateType entityState) : this(field, position, CrazyCrawlEnemy.BodyStates(), entityState) { }
public CrazyCrawlEnemy(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { // you can override here initial bomb movement direction values set in base constructor this.DeltaX = -2; this.DeltaY = 0; }
protected Enemy(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { // defines initial enemy movement direction values this.DeltaX = -1.0M; this.DeltaY = 0M; this.EnemyPositionX = position.X; this.EnemyPositionY = position.Y; this.bullets = new List <Bullet>(); this.missiles = new List <Missile>(); this.IsShootingEnabled = false; }
public LightweightBullet(Field field, Point2D position, EntityStateType entityState) : this(field, position, LightweightBullet.BodyStates(), entityState) { }
protected Building(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { this.positionX = position.X; }
public LightweightBullet(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { // defines bullet movement direction this.DeltaX = 3; this.DeltaY = 0; }
public BadShooterEnemy(Field field, Point2D position, EntityStateType entityState) : this(field, position, BadShooterEnemy.BodyStates(), entityState) { }
public SimplePanelka(Field field, Point2D position, EntityStateType entityState) : this(field, position, SimplePanelka.BodyStates(), entityState) { }
protected Missile(Field field, Point2D position, IList <IList <Pixel> > bodyStates, EntityStateType entityState) : base(field, position, bodyStates, entityState) { }
public SimpleHouse(Field field, Point2D position, EntityStateType entityState) : this(field, position, SimpleHouse.BodyStates(), entityState) { }