public CControl(SPGame mGame, CStats mCStats, CBody mCBody, CMovement mCMovement, CRender mCRender) { _game = mGame; _cStats = mCStats; _cBody = mCBody; _cMovement = mCMovement; _cRender = mCRender; }
public CHealth(CStats mCStats) { _cStats = mCStats; RecalculateMaxHealth(); _health = _maxHealth; _cStats.Strength.OnChanged += RecalculateMaxHealth; _cStats.Endurance.OnChanged += RecalculateMaxHealth; }
public CAI(SPGame mGame, CStats mCStats, CBody mCBody, CMovement mCMovement, CRender mCRender, CLineOfSight mCLineOfSight) { _game = mGame; _cStats = mCStats; _cBody = mCBody; _cLineOfSight = mCLineOfSight; _cMovement = mCMovement; _cRender = mCRender; WaitAmplitude = _cStats.Speed.Total/5f + 50; WaitDelayMax = 450 - _cStats.Speed.Total/5 + _cStats.Endurance.Total*5f; BulletSpeedBase = 150 + _cStats.Agility.Total*8; BulletSpeedMax = 400 + _cStats.Agility.Total*10; BulletSpeedIncrease = 25 + _cStats.Agility.Total*3; WanderingDirectionDelayMax = 50 - _cStats.Speed.Total/8f; WanderingSpeed = _cStats.Speed.Total; ChaseSpeed = _cStats.Speed.Total/10f; ShootDelayMax = 40 - _cStats.Agility.Total/8f; _bulletSpeed = BulletSpeedBase; mCBody.OnCollision += (mCollisionInfo) => { var entity = (Entity) mCollisionInfo.UserData; if (entity.HasTag(Tags.Wall)) { if (_state == StateWandering && _turnAroundDelay <= 0) { _turnAroundDelay = TurnAroundDelayMax; _currentDirection += 90*Utils.Random.NextSign(); } } if (entity.HasTag(Tags.BulletFriendly)) { _state = StateWait; var vector = mCollisionInfo.Body.Position - mCollisionInfo.Body.Velocity*5; _currentDirection = Utils.Math.Angles.TowardsDegrees(new SSVector2F(_cBody.X, _cBody.Y), new SSVector2F(vector)); } }; }
public CAI(SPGame mGame, CStats mCStats, CBody mCBody, CMovement mCMovement, CRender mCRender, CLineOfSight mCLineOfSight) { _game = mGame; _cStats = mCStats; _cBody = mCBody; _cLineOfSight = mCLineOfSight; _cMovement = mCMovement; _cRender = mCRender; WaitAmplitude = _cStats.Speed.Total / 5f + 50; WaitDelayMax = 450 - _cStats.Speed.Total / 5 + _cStats.Endurance.Total * 5f; BulletSpeedBase = 150 + _cStats.Agility.Total * 8; BulletSpeedMax = 400 + _cStats.Agility.Total * 10; BulletSpeedIncrease = 25 + _cStats.Agility.Total * 3; WanderingDirectionDelayMax = 50 - _cStats.Speed.Total / 8f; WanderingSpeed = _cStats.Speed.Total; ChaseSpeed = _cStats.Speed.Total / 10f; ShootDelayMax = 40 - _cStats.Agility.Total / 8f; _bulletSpeed = BulletSpeedBase; mCBody.OnCollision += (mCollisionInfo) => { var entity = (Entity)mCollisionInfo.UserData; if (entity.HasTag(Tags.Wall)) { if (_state == StateWandering && _turnAroundDelay <= 0) { _turnAroundDelay = TurnAroundDelayMax; _currentDirection += 90 * Utils.Random.NextSign(); } } if (entity.HasTag(Tags.BulletFriendly)) { _state = StateWait; var vector = mCollisionInfo.Body.Position - mCollisionInfo.Body.Velocity * 5; _currentDirection = Utils.Math.Angles.TowardsDegrees(new SSVector2F(_cBody.X, _cBody.Y), new SSVector2F(vector)); } }; }
public Entity Enemy(int mX, int mY) { var result = new Entity(_manager); var cStats = new CStats(1, 1, 1, 75); var cHealth = new CHealth(cStats); var cBody = Body(new SSVector2I(mX, mY), 10.ToUnits(), 10.ToUnits()); var cMovement = Movement(cBody); var cRender = Render(cBody, Textures.CharEnemy, Tilesets.Char, "normal"); var cShadower = new CShadower(_game, cBody, false, new Color(125, 255, 125, 125)); var cLineOfSight = new CLineOfSight(_game, cBody, cShadower) {TargetTag = Tags.Friendly, Angle = 90, Amplitude = 65}; var cAI = AI(cStats, cBody, cMovement, cRender, cLineOfSight); cBody.Body.AddGroups(Groups.Character, Groups.Enemy); cBody.Body.AddGroupsToCheck(Groups.Obstacle); result.AddComponents(cHealth, cBody, cMovement, cRender, cShadower, cLineOfSight, cAI); result.AddTags(Tags.Char, Tags.Enemy, Tags.DamagedByFriendly); return result; }
private CControl Control(CBody mCBody, CStats mCStats, CMovement mCMovement, CRender mCRender) { return new CControl(_game, mCStats, mCBody, mCMovement, mCRender); }
private CAI AI(CStats mCStats, CBody mCBody, CMovement mCMovement, CRender mCRender, CLineOfSight mCLineOfSight) { return new CAI(_game, mCStats, mCBody, mCMovement, mCRender, mCLineOfSight); }
public Entity Player(int mX, int mY) { var result = new Entity(_manager); var cStats = new CStats(1, 1, 1, 50); var cHealth = new CHealth(cStats); var cBody = Body(new SSVector2I(mX, mY), 10.ToUnits(), 10.ToUnits()); var cMovement = Movement(cBody); var cRender = Render(cBody, Textures.CharPlayer, Tilesets.Char, "normal"); var cControl = Control(cBody, cStats, cMovement, cRender); var cShadower = new CShadower(_game, cBody, true, new Color(77, 77, 175, 255), 1); cBody.Body.AddGroups(Groups.Character, Groups.Friendly); cBody.Body.AddGroupsToCheck(Groups.Obstacle); result.AddComponents(cStats, cHealth, cBody, cMovement, cControl, cRender, cShadower); result.AddTags(Tags.Char, Tags.Friendly, Tags.DamagedByEnemy); return result; }