public PumpController(GameEntity e) : base(e) { processTime_ = 1; isDrawn = true; search = true; }
public ProductionComponent(GameEntity entity, ItemInfo input, ItemInfo output, float productionTime) : base(entity, 2) { input_ = input; output_ = output; productionTime_ = productionTime; }
public override void ExitState(GameEntity unit) { base.ExitState(unit); unit.StopMovement(); Debug.Log("Stopping chasing enemy"); }
public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState ) { if ( control is Projectile ) { HashSet<Tank> tanks = new HashSet<Tank>(); if ( control.Variables.ContainsKey( "Hypnotize" ) ) { tanks = ( ( HashSet<Tank> )control.Variables[ "Hypnotize" ] ); } if ( Vector2.Distance( control.Position, Owner.Position ) < rad )// && !Tools.IsGoingTowardsMe( Owner.Position, control.Angle, control.Position ) ) { if ( !control.Variables.ContainsKey( "Hypnotize" ) || !tanks.Contains( Owner ) ) { DeflectorController d = new DeflectorController( Tools.Angle( Owner.Position, control.Position ) ); control.AppendController( d ); tanks.Add( Owner ); } } else { tanks.Remove( Owner ); } control.Variables[ "Hypnotize" ] = tanks; } return base.Control( control, gameTime, keyState ); }
public void Update(Seizonsha game, GameEntity entity) { if (recharged < recharge_time) { recharged++; } }
public SpatialComponent(GameEntity entity, Vector2 translation, float rotation, Vector2 scale) : base(entity) { translation_ = translation; rotation_ = rotation; scale_ = scale; }
public DriftPhysics(GameEntity entity, Vector2 drift, Vector2 speed, float d_speed) : base(entity, Vector2.Zero, 0, Vector2.Zero) { max_drift = drift; max_speed = speed; drift_speed = d_speed; }
public Removing(GameEntity entity) { entity_ = entity; currentTime_ = 0; processTime_ = 0.5f; bar_ = new UI.ProgressBar(50); }
public void Use(Seizonsha game, GameEntity entity) { // entity is whatever is using this // if (entity.isFrozen()) // { // return; // } recharged = 0; // entity.Freeze(recharge_time); int damageType = Static.DAMAGE_TYPE_NO_DAMAGE; if (entity.getTargetType() == Static.TARGET_TYPE_FRIENDLY){ damageType = Static.DAMAGE_TYPE_FRIENDLY; } if (entity.getTargetType() == Static.TARGET_TYPE_ENEMY){ damageType = Static.DAMAGE_TYPE_ENEMY; } Rectangle slashBounds = new Rectangle( entity.getCenterX(), entity.getCenterY(), Static.PLAYER_WIDTH/2, Static.PLAYER_HEIGHT/2); //Rectangle bulletBounds = new Rectangle( game.Spawn(new Bullet(game, game.getTestSprite(slashBounds, Color.Red), slashBounds, damage, damageType, 1, bulletSpeed, entity.alexDirection)); // game sprite bounds amount dmgAmount dmgType duration bulletSpeed }
public void refresh(GameEntity item) { item_ = item; count_.text_ = "" + item.item.number_; count_.pack(); count_.loc_ = new Vector2(buttonSize) - count_.size; }
public InventoryComponent(GameEntity entity, int cap, int perSlot = 5) : base(entity) { capacity_ = cap; items_ = new GameEntity[capacity_]; numberPerSlot_ = perSlot; }
private void DisableRespawn(EntityPlacement placement, GameEntity entity) { if (placement.respawn != RespawnBehavior.Offscreen) _respawnableEntities[placement] = false; entity.Removed -= () => DisableRespawn(placement, entity); }
public GameEntity createEndGameFlame() { GameEntity e = new GameEntity(); e.render = new RenderComponent(e, Locator.getTextureManager().loadTexture("flame"), 0, new Vector2(96, 40), Color.White); e.spatial = new SpatialComponent(e, Locator.getShip().entity_.spatial, new Vector2(-16, 336), 0, Vector2.One); return e; }
public override void UpdateState(GameEntity unit) { base.UpdateState(unit); if (_unitToAttack == null || _unitToAttack.IsDead()) { unit.GetStateMachine().ChangeState(new RestState()); return; } Vector3 unitToAttackPos = _unitToAttack.GetPos(); // As the unit must move towards a dynamic position. unit.MoveTo(unitToAttackPos); float extra = _unitToAttack is GameBuilding ? GameBuilding.EXTRA_ATTACK_DIST : 0.0f; float attackRange = unit.GetAttackRange() + extra; // Is the unit within attacking distance of the unit to attack? float distance = Vector3.Distance(unitToAttackPos, unit.GetPos()); if (distance < (attackRange - ARRIVE_THRESHOLD)) { // Start attacking the other object. unit.GetStateMachine().ChangeState(new AttackState(_unitToAttack)); } }
public PhysicsComponent(GameEntity entity, Vector2 velocity, float spin, Vector2 growth) : this(entity) { velocity_ = velocity; spin_ = spin; growth_ = growth; }
public GameEntity CreateEntityWithId(string id, string name) { // look in the pool if (deadEntityPool.ContainsKey(name) && deadEntityPool[name].Any()) { var entity = deadEntityPool[name].Pop(); BindEntityEventRegistration(id, entity); return entity; } else { // clone it GameEntity entity = new GameEntity(); GameEntity source = _entitySource.GetOriginalEntity(name); if (GetNumberAlive(name) >= source.MaxAlive) return null; foreach (Component c in source.Components) { entity.AddComponent(c.Clone()); } entity.Name = source.Name; entity.OnDeath = source.OnDeath; entity.IsGravitySensitive = source.IsGravitySensitive; BindEntityEventRegistration(id, entity); return entity; } }
public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState ) { if ( selectedTank == null ) { List<Tank> TanksCopy = new List<Tank>( Tanks ); if ( TanksCopy.Count == 0 ) return true; int i = r.Next( TanksCopy.Count ); while ( TanksCopy[ i ].Controller is MindController ) { TanksCopy.RemoveAt( i ); i = r.Next( TanksCopy.Count ); if ( TanksCopy.Count == 0 ) return true; } selectedTank = TanksCopy[ i ]; } if ( controlKeys == null ) { controlKeys = selectedTank.Keys; selectedTank.Keys = Owner.Keys; Owner.Keys = new KeySet( Keys.None, Keys.None, Keys.None, Keys.None, Owner.Keys.KeyPlace, Keys.None ); } base.Control( control, gameTime, keyState ); return true; }
public TileCoord(GameEntity entity, Point coord, Point size, TileSystemComponent tileSystem) : base(entity) { tileSystem_ = tileSystem; coord_ = coord; size_ = size; }
public override void InstantControl( GameEntity control, TimeSpan gameTime ) { float closestDistance = -1; // The distance to the closest tank Tank closestTank = null; // The closest tank // Find the closest living tank foreach ( Tank t in Tanks ) { float dist = Vector2.DistanceSquared( Owner.Position, t.Position ); if ( t.IsAlive ) { if ( ( closestTank == null || dist < closestDistance ) ) { closestDistance = dist; closestTank = t; } } } if ( closestTank != null ) // If no tank is alive don't do anything { // Set owner's angle float ang = Tools.Angle( control.Position, closestTank.Position ); DeflectorController c = new DeflectorController( ang ); control.AppendController( c ); } }
public PlayerControllerComponent(GameEntity entity) : base(entity) { keys = new bool[4]; direction = Vector2.Zero; dir_dirty = true; }
public WorldController(GameEntity entity, Point screen) : base(entity) { screen_ = screen; Locator.getMessageBoard().register(listen); }
public override bool HasValidPlays(GameEntity entity) { if (entity.EntityView.InPlay) { return true; } return false; }
public override bool HasValidPlays(GameEntity entity) { if(entity.PrototypeId == prototypeId) { return true; } return false; }
public SpatialComponent(GameEntity entity, SpatialComponent parent) : base(entity) { parent_ = parent; translation_ = Vector2.Zero; rotation_ = 0f; scale_ = Vector2.One; }
public override Component deepCopy(GameEntity entity) { ParticleController c = new ParticleController(entity, life_); c.timed = timed; c.fadeSpeed = fadeSpeed; c.opacity = opacity; return c; }
public override bool AddEntity( GameEntity entity ) { if ( entity is Projectile && !( entity is Rider || entity is Lazer || entity is LazerHelper ) ) { return true; } return false; }
public RenderComponent(GameEntity entity, int texture_id, int layer, Vector2 origin, Color color) : this(entity) { texture_id_ = texture_id; layer_ = layer; origin_ = origin; color_ = color; }
public override bool AddEntity( GameEntity entity ) { if ( entity is Tank ) { Tanks.Add( ( Tank )entity ); } return false; }
public override bool HasValidPlays(GameEntity entity) { if (entity.EntityView.InPlay) { if(entity.EntityView.column == fromX && entity.EntityView.row == fromY) return true; } return false; }
public override bool Control( GameEntity control, TimeSpan gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyState ) { if ( control == Owner && Owner.IsAlive && keyState.IsKeyDown( Owner.Keys.KeyShoot ) && ( lastShot == TimeSpan.Zero || ( gameTime - lastShot ).TotalMilliseconds > speed ) ) { Owner.Shoot( gameTime ); lastShot = gameTime; } return base.Control( control, gameTime, keyState ); }
private void ArrangeDestructedMeshes() { float num1 = 0.0f; foreach (float hitPointPercentage in this._wallHitPointPercentages) { num1 += hitPointPercentage; } if (!((IEnumerable <float>) this._wallHitPointPercentages).IsEmpty <float>()) { num1 /= (float)this._wallHitPointPercentages.Length; } float num2 = MBMath.Lerp(0.0f, 0.7f, 1f - num1); IEnumerable <SynchedMissionObject> source1 = this.Mission.MissionObjects.OfType <SynchedMissionObject>(); IEnumerable <DestructableComponent> destructibleComponents = source1.OfType <DestructableComponent>(); foreach (StrategicArea strategicArea in this.Mission.ActiveMissionObjects.OfType <StrategicArea>().ToList <StrategicArea>()) { strategicArea.DetermineAssociatedDestructibleComponents(destructibleComponents); } foreach (SynchedMissionObject synchedMissionObject in source1) { if (this._hasAnySiegeTower && synchedMissionObject.GameEntity.HasTag("tower_merlon")) { synchedMissionObject.SetVisibleSynched(false, true); } else { DestructableComponent firstScriptOfType = synchedMissionObject.GameEntity.GetFirstScriptOfType <DestructableComponent>(); if (firstScriptOfType != null && firstScriptOfType.CanBeDestroyedInitially && ((double)num2 > 0.0 && (double)MBRandom.RandomFloat <= (double)num2)) { firstScriptOfType.PreDestroy(); } } } if ((double)num2 >= 0.100000001490116) { List <GameEntity> list = this.Mission.Scene.FindEntitiesWithTag("damage_decal").ToList <GameEntity>(); foreach (GameEntity gameEntity in list) { gameEntity.GetFirstScriptOfType <SynchedMissionObject>().SetVisibleSynched(false); } for (double num3 = Math.Floor((double)list.Count * (double)num2); num3 > 0.0; --num3) { GameEntity gameEntity = list[MBRandom.RandomInt(list.Count)]; list.Remove(gameEntity); gameEntity.GetFirstScriptOfType <SynchedMissionObject>().SetVisibleSynched(true); } } List <WallSegment> source2 = new List <WallSegment>(); List <WallSegment> list1 = this.Mission.ActiveMissionObjects.FindAllWithType <WallSegment>().Where <WallSegment>((Func <WallSegment, bool>)(ws => ws.DefenseSide != FormationAI.BehaviorSide.BehaviorSideNotSet && ws.GameEntity.GetChildren().Any <GameEntity>((Func <GameEntity, bool>)(ge => ge.HasTag("broken_child"))))).ToList <WallSegment>(); int val2 = 0; foreach (float hitPointPercentage in this._wallHitPointPercentages) { if ((double)Math.Abs(hitPointPercentage) < 9.99999974737875E-06) { ++val2; } } int num4 = Math.Min(list1.Count <WallSegment>(), val2); while (num4 > 0) { WallSegment randomElement = list1.GetRandomElement <WallSegment>(); randomElement.OnChooseUsedWallSegment(true); list1.Remove(randomElement); --num4; source2.Add(randomElement); } foreach (WallSegment wallSegment in list1) { wallSegment.OnChooseUsedWallSegment(false); } if ((double)num2 < 0.100000001490116) { return; } List <SiegeWeapon> siegeWeaponList = new List <SiegeWeapon>(); foreach (SiegeWeapon siegeWeapon in this.Mission.ActiveMissionObjects.FindAllWithType <SiegeWeapon>().Where <SiegeWeapon>((Func <SiegeWeapon, bool>)(sw => sw is IPrimarySiegeWeapon))) { SiegeWeapon primarySiegeWeapon = siegeWeapon; if (source2.Any <WallSegment>((Func <WallSegment, bool>)(b => b.DefenseSide == ((IPrimarySiegeWeapon)primarySiegeWeapon).WeaponSide))) { siegeWeaponList.Add(primarySiegeWeapon); } } siegeWeaponList.ForEach((Action <SiegeWeapon>)(siegeWeaponToRemove => siegeWeaponToRemove.SetDisabledSynched())); }
public static void Update(AbstractGameObject unit) { var EvolutionTime = unit.EvolutionTime; if (unit.State != EventManager.InProgressEvents.Stay) { ProgressUnitBar.RemoveProgressBar(unit); if (stackTarget.ContainsKey(unit)) { var target = stackTarget[unit]; var progressName = ProgressUnitBar.ProgressName.GroupEvolution; ProgressUnitBar.RemoveProgressBar(target, progressName); stackTarget.Remove(unit); stackTarget.Remove(target); } return; } var chunk = ChunkManager.GetChunkByNum(unit.ChunkNumber); //Solo evolution if (unit.SoloEvolution) { var progressName = ProgressUnitBar.ProgressName.SoloEvolution; var pos = unit.CurrentPos; if (!SecondaryGroundLvL.IsEmptyPos(chunk.ChunkNumber, pos) && ChunkUtil.IsAnyEntity(chunk.ChunkNumber, pos)) { ProgressUnitBar.RemoveProgressBar(unit, progressName); return; } ProgressUnitBar.Setup(unit, progressName, EvolutionTime); if (!ProgressUnitBar.IsReady(unit) || !ProgressUnitBar.IsThisProgressName(unit, progressName)) { return; } // Debug.Log("Original name = " + unit.OriginalName); if (SoloEvolutionDict.ContainsKey(unit.OriginalName) || unit.EvolutionNext.Length > 0) { var evoName = ""; evoName = unit.EvolutionNext.Length == 0 ? SoloEvolutionDict[unit.OriginalName] : unit.EvolutionNext; if (evoName.Length > 0) { // Debug.Log("Evolution name = " + evoName); var prevIndex = ChunkUtil.GetIndex(chunk.ChunkNumber, pos); var prevEnt = chunk.GetGameObjectByIndex(pos); var check = unit.PrefabIndex == prevIndex; unit.KillSelf(); if (!SecondaryGroundLvL.IsEmptyPos(chunk.ChunkNumber, pos)) { SecondaryGroundLvL.GetGroundEnt(chunk.ChunkNumber, pos).KillSelf(); SecondaryGroundLvL.RemovePos(chunk.ChunkNumber, pos); } var ent = chunk.PreSetupObject(evoName, pos, unit.Owner); if (GroupUtil.isBuilding(ent.Group) || GroupUtil.IsItem(ent.Group)) { chunk.SetupItem(ent, evoName, pos, unit.Owner); } else { chunk.SetupUnit(ent, evoName, pos, unit.Owner); } } } } //Group evolution else if (stackResult.ContainsKey(unit.OriginalName)) { var progressName = ProgressUnitBar.ProgressName.GroupEvolution; var friends = AI_Calculation.GetNearFriendUnits(chunk.ChunkNumber, unit, unit.CurrentPos); GameEntity target = null; if (stackTarget.ContainsKey(unit)) { target = stackTarget[unit]; } if (target != null && !friends.Contains(target as GameUnit)) { ProgressUnitBar.RemoveProgressBar(target, progressName); target = null; stackTarget.Remove(unit); } foreach (var obj in friends) { if (obj.Destroyed) { continue; } if (!stackResult[unit.OriginalName].ContainsKey(obj.OriginalName)) { continue; } if (obj.State != EventManager.InProgressEvents.Stay) { continue; } stackTarget[unit] = obj; target = obj; break; } if (target == null) { return; } ProgressUnitBar.Setup(unit, progressName, EvolutionTime); //EvolutionTimeList[target] = EvolutionTimeList[ent]; // UpdateProgressBar(target); if (!ProgressUnitBar.IsReady(unit) || !ProgressUnitBar.IsThisProgressName(unit, progressName)) { return; } var evoName = stackResult[unit.OriginalName][target.OriginalName]; var pos = unit.CurrentPos; var owner = unit.Owner; unit.KillSelf(); target.KillSelf(); var evoUnit = chunk.SetupUnit(evoName, pos, owner); QuestManager.OnEvolution(evoUnit); Coloring.RecolorObject(ChunkUtil.GetDovvner(unit.CurrentPos)); Coloring.RecolorObject(ChunkUtil.GetDovvner(target.CurrentPos)); UnitEvents.OnEvolution(evoUnit); PathCalcManager.CalculatePoint(ChunkUtil.GetDovvner(pos)); PathCalcManager.CalculatePoint(pos); } }
private bool IsSkillActivite() { GameEntity self = GetOwner(); return(self.hasSkill && null != self.skill.Instance); }
public static int GetAmountOfWorkers(GameEntity e, GameContext gameContext) { return(e.team.Workers[WorkerRole.Programmer] + e.team.Managers.Count); }
internal static int GetUniversals(GameEntity company) { return(CountSpecialists(company, WorkerRole.Universal)); }
public static int GetProgrammers(GameEntity company) { return(CountSpecialists(company, WorkerRole.Programmer)); }
protected override bool StateConditon(GameEntity entity) { return(entity.gameHumanBehaviourState.Behaviour == PlayerBehaviourIndex.WALK || entity.gameHumanBehaviourState.Behaviour == PlayerBehaviourIndex.RUN); }