private bool Login(string username, string password) { try { AccountManagerErrorCode errorCode; Guid?id = _service.Login(username, HashHelper.GetMd5Hash(password), out errorCode); if (id != null) { _me = new AGameObject() { Coordinates = Vector2.Zero, Id = (Guid)id }; SetStatus("Logon successfull"); return(true); } SetStatus(String.Format("ERROR: {0}", errorCode)); return(false); } catch (Exception) { return(false); } }
public void Draw(Graphics graph, AGameObject gameObject) { if (gameObject is AFish) { Draw(graph, (AFish)gameObject); } }
public TurretGun(Guid id, Vector2 parentTurretCoordinates, AGameObject owner = null) : base(id, owner) { WeaponType = WeaponType.TurretGun; ReloadSpeed = Constants.TURRET_GUN_ATTACK_RATE; this._parentTurretCoordinates = parentTurretCoordinates; }
private void ApplyEvents(IEnumerable <AGameEvent> events) { if (events == null) { return; } foreach (var gameEvent in events) { var t = _objects.FindAll(o => o == null); if (t.Count != 0) { Trace.WriteLine(t); } var gameObject = _objects.Find(o => o != null && o.Id == gameEvent.GameObjectId); if (gameObject != null) { gameEvent.UpdateMob(gameObject); } else { var newObj = new AGameObject(); gameEvent.UpdateMob(newObj); _objects.Add(newObj); } } }
public override IEnumerable <AGameEvent> Do(AGameObject obj, List <AGameObject> newObjects, long time) { var res = new List <AGameEvent>(base.Do(obj, newObjects, time)); if (obj.TeamIdentity != Owner.TeamIdentity && obj.Is(EnumObjectType.Block) && !obj.Is(EnumObjectType.Poisoning)) { int circles; if (Damage / Constants.ROCKET_BULLET_DAMAGE > 1) { circles = Constants.ROCKET_EXPLOSION_CIRCLES + 2; } else { circles = Constants.ROCKET_EXPLOSION_CIRCLES; } var explosion = new Explosion(Owner, Guid.NewGuid(), Coordinates, circles, 1) { Radius = Constants.ROCKET_EXPLOSION_RADIUS, Damage = Constants.ROCKET_EXPLOSION_DAMAGE, }; res.Add(new NewObjectEvent(explosion, time)); newObjects.Add(explosion); } return(res); }
public override void MouseClick(int x, int y) { if (!gameModel.CanClientInput) { return; } foreach (var go in gameMatrix) { if (go.Region.Contains(x, y)) { if (selected != null) { if (selected.Left == go || selected.Right == go) { gameModel.ClientSwapH(selected, go); selected = null; return; } else if (selected.Top == go || selected.Bottom == go) { gameModel.ClientSwapV(selected, go); selected = null; return; } selected.Selected = false; selected = null; } selected = go; selected.Selected = true; } } }
public DrawableGameObject(AGameObject other, Animation2D animation) { Animation = animation; Animation.Initialize(FRAME_TIME, LOOPING); Copy(other); MakeOriginalRadius(); }
public Shotgun(Guid id, AGameObject owner = null) : base(id, owner) { _rand = new Random(); WeaponType = WeaponType.Shotgun; ReloadSpeed = Constants.SHOTGUN_ATTACK_RATE; }
public override IEnumerable <AGameEvent> Do(AGameObject obj, List <AGameObject> newObjects, long time) { var res = new List <AGameEvent>(base.Do(obj, newObjects, time)); Bonuses.AGameBonus mirror = null; if (obj.Is(EnumObjectType.Player)) { var afflicted = obj as MainSkyShootService; //Ради проверки на наличие зеркала if (afflicted != null) { mirror = afflicted.GetBonus(EnumObjectType.Mirror); } } if (obj.Is(EnumObjectType.LivingObject) && (obj.HealthAmount >= Constants.POISON_BULLET_DAMAGE) && (mirror == null) && (obj.TeamIdentity != Owner.TeamIdentity) && !obj.Is(EnumObjectType.Turret)) { var wp = new Pistol(Guid.NewGuid()); //Просто для конструктора. Заглушка. var poison = new Poisoning(Constants.POISONING_TICK_TIMES, wp, obj) { ObjectType = EnumObjectType.Poisoning, }; //Время жизни--через здоровье newObjects.Add(poison); } //Отравление реализовано через создание моба. Он отправляется за край карты, и оттуда крадёт здоровье у своей жертвы. return(res); }
public DrawableGameObject(AGameObject other, Texture2D staticTexture) { Animation = null; StaticTexture = staticTexture; Copy(other); MakeOriginalRadius(); }
public static AGameObject OneObject(AGameObject gameObject) { var gameObjectCopy = new AGameObject(); gameObjectCopy.Copy(gameObject); return(gameObjectCopy); }
protected void SomebodyShot(AGameObject sender, Vector2 direction) { sender.ShootVector = direction; sender.ShootVector.Normalize(); if (sender.Weapon != null) { if (sender.Weapon.IsReload(DateTime.Now.Ticks / 10000)) { var bullets = sender.Weapon.CreateBullets(direction); var player = sender as MainSkyShootService; if (player != null) { AGameBonus doubleDamage = player.GetBonus(AGameObject.EnumObjectType.DoubleDamage); float damage = doubleDamage == null ? 1f : doubleDamage.DamageFactor; player.Weapon.ApplyModifier(bullets, damage); } foreach (var bullet in bullets) { lock (_newObjects) { _newObjects.Add(bullet); PushEvent(new NewObjectEvent(bullet, _timeHelper.GetTime())); } } //Trace.WriteLine("projectile added", "GameSession"); } } }
public static AGameObject OneObject(AGameObject m) { var o = new AGameObject(); o.Copy(m); return(o); }
public TurretGunBullet(AGameObject owner, Guid id, Vector2 direction, Vector2 turretPosition) : base(owner, id, direction, turretPosition) { Speed = Constants.TURRET_GUN_BULLET_SPEED; Damage = Constants.TURRET_GUN_BULLET_DAMAGE; HealthAmount = Constants.TURRET_GUN_BULLET_LIFE_DISTANCE; ObjectType = EnumObjectType.TurretGunBullet; }
public PistolBullet(AGameObject owner, Guid id, Vector2 direction) : base(owner, id, direction) { Speed = Constants.PISTOL_BULLET_SPEED; Damage = Constants.PISTOL_BULLET_DAMAGE; HealthAmount = Constants.PISTOL_BULLET_LIFE_DISTANCE; ObjectType = EnumObjectType.PistolBullet; }
protected void SomebodyMoved(AGameObject sender, Vector2 direction) { sender.RunVector = direction; lock (_gameObjects) { PushEvent(new ObjectDirectionChanged(direction, sender.Id, _timeHelper.GetTime())); } }
public ShotgunBullet(AGameObject owner, Guid id, Vector2 direction) : base(owner, id, direction) { Speed = Constants.SHOTGUN_BULLET_SPEED; Damage = Constants.SHOTGUN_BULLET_DAMAGE; HealthAmount = Constants.SHOTGUN_BULLET_LIFE_DISTANCE; ObjectType = EnumObjectType.ShotgunBullet; }
public PoisonTick(AGameObject owner, Guid id, Vector2 direction) : base(owner, id, direction) { Speed = Constants.POISONTICK_BULLET_SPEED; Damage = Constants.POISONTICK_BULLET_DAMAGE; HealthAmount = Constants.POISONTICK_BULLET_LIFE_DISTANCE; ObjectType = EnumObjectType.PoisonTick; }
//TODO: make uniform constructor? protected AProjectile(AGameObject owner, Guid id, Vector2 direction, Vector2 birthPlace) { Owner = owner; Id = id; ShootVector = RunVector = direction; Coordinates = birthPlace; Radius = Constants.DEFAULT_BULLET_RADIUS; _mirrored = false; }
public ThirdPersonCamera(AGameObject target, Vector3 offset) { _target = target; _offset = offset; Vector3 possition; possition.X = possition.Y = possition.Z = 0; LookAtMatrix = Matrix4.LookAt(possition, -Vector3.UnitZ, Vector3.UnitY); }
public FirstPersonCamera(AGameObject target, Vector3 offset) { _target = target; _offset = offset; Vector3 possition; possition.X = _target.possition.X; possition.Y = _target.possition.Y; possition.Z = _target.possition.Z; LookAtMatrix = Matrix4.LookAt(new Vector3(_target.possition) + _offset, new Vector3(_target.possition), Vector3.UnitY); }
public RocketBullet(AGameObject owner, Guid id, Vector2 direction) : base(owner, id, direction) { Speed = Constants.ROCKET_BULLET_SPEED; Damage = Constants.ROCKET_BULLET_DAMAGE; HealthAmount = Constants.ROCKET_BULLET_LIFE_DISTANCE; Radius = Constants.ROCKET_BULLET_RADIUS; ObjectType = EnumObjectType.RocketBullet; }
public override void OnCollision(AGameObject anotherObject) { if (anotherObject != Victim) { return; } Victim.Die(); Victim = null; }
public HeaterBullet(AGameObject owner, Guid id, Vector2 direction) : base(owner, id, direction) { Speed = Constants.HEATER_BULLET_SPEED; Damage = Constants.HEATER_BULLET_DAMAGE; HealthAmount = Constants.HEATER_BULLET_LIFE_DISTANCE; //!! 2 do сделать отдельный пункт енума ObjectType = EnumObjectType.HeaterBullet; }
public override void OnCollision(AGameObject anotherObject) { if (anotherObject != Victim || State != FishState.Attack) { return; } Victim.Die(); Victim = null; }
public Flame(AGameObject owner, Guid id, Vector2 direction, Vector2 coordinates) : base(owner, id, direction) { Coordinates = coordinates; Speed = Constants.FLAME_SPEED; Damage = Constants.FLAME_DAMAGE; HealthAmount = Constants.FLAME_LIFE_DISTANCE; Radius = Constants.FLAME_RADIUS; ObjectType = EnumObjectType.Flame; }
public void ClientSwapH(AGameObject go1, AGameObject go2) { GameMatrix.SwapH(go1, go2); clientSwapModel = new SwapModel { GameObject1 = go1, GameObject2 = go2, Direction = SwapDirection.HORIZONTAL }; }
public void ClientSwapV(AGameObject go1, AGameObject go2) { GameMatrix.SwapV(go1, go2); clientSwapModel = new SwapModel { GameObject1 = go1, GameObject2 = go2, Direction = SwapDirection.VERTICAL }; }
public static AGameObject[] ArrayedObjects(AGameObject[] ms) { var rs = new AGameObject[ms.Length]; for (int i = 0; i < ms.Length; i++) { rs[i] = new AGameObject(); rs[i].Copy(ms[i]); } return(rs); }
public override void Copy(AGameObject other) { base.Copy(other); var m = other as Mob; if (m == null) { return; //!! throw } Target = m.Target; }