Esempio n. 1
0
        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);
     }
 }
Esempio n. 3
0
 public TurretGun(Guid id, Vector2 parentTurretCoordinates, AGameObject owner = null)
     : base(id, owner)
 {
     WeaponType  = WeaponType.TurretGun;
     ReloadSpeed = Constants.TURRET_GUN_ATTACK_RATE;
     this._parentTurretCoordinates = parentTurretCoordinates;
 }
Esempio n. 4
0
 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);
         }
     }
 }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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;
                }
            }
        }
Esempio n. 7
0
 public DrawableGameObject(AGameObject other, Animation2D animation)
 {
     Animation = animation;
     Animation.Initialize(FRAME_TIME, LOOPING);
     Copy(other);
     MakeOriginalRadius();
 }
Esempio n. 8
0
 public Shotgun(Guid id, AGameObject owner = null)
     : base(id, owner)
 {
     _rand       = new Random();
     WeaponType  = WeaponType.Shotgun;
     ReloadSpeed = Constants.SHOTGUN_ATTACK_RATE;
 }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
 public DrawableGameObject(AGameObject other, Texture2D staticTexture)
 {
     Animation     = null;
     StaticTexture = staticTexture;
     Copy(other);
     MakeOriginalRadius();
 }
Esempio n. 11
0
        public static AGameObject OneObject(AGameObject gameObject)
        {
            var gameObjectCopy = new AGameObject();

            gameObjectCopy.Copy(gameObject);
            return(gameObjectCopy);
        }
Esempio n. 12
0
        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");
                }
            }
        }
Esempio n. 13
0
        public static AGameObject OneObject(AGameObject m)
        {
            var o = new AGameObject();

            o.Copy(m);
            return(o);
        }
Esempio n. 14
0
 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;
 }
Esempio n. 15
0
 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;
 }
Esempio n. 16
0
 protected void SomebodyMoved(AGameObject sender, Vector2 direction)
 {
     sender.RunVector = direction;
     lock (_gameObjects)
     {
         PushEvent(new ObjectDirectionChanged(direction, sender.Id, _timeHelper.GetTime()));
     }
 }
Esempio n. 17
0
 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;
 }
Esempio n. 18
0
 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;
 }
Esempio n. 19
0
 //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);
        }
Esempio n. 21
0
        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);
        }
Esempio n. 22
0
 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;
 }
Esempio n. 23
0
 public override void OnCollision(AGameObject anotherObject)
 {
     if (anotherObject != Victim)
     {
         return;
     }
     Victim.Die();
     Victim = null;
 }
Esempio n. 24
0
 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;
 }
Esempio n. 25
0
 public override void OnCollision(AGameObject anotherObject)
 {
     if (anotherObject != Victim || State != FishState.Attack)
     {
         return;
     }
     Victim.Die();
     Victim = null;
 }
Esempio n. 26
0
 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;
 }
Esempio n. 27
0
 public void ClientSwapH(AGameObject go1, AGameObject go2)
 {
     GameMatrix.SwapH(go1, go2);
     clientSwapModel = new SwapModel
     {
         GameObject1 = go1,
         GameObject2 = go2,
         Direction   = SwapDirection.HORIZONTAL
     };
 }
Esempio n. 28
0
 public void ClientSwapV(AGameObject go1, AGameObject go2)
 {
     GameMatrix.SwapV(go1, go2);
     clientSwapModel = new SwapModel
     {
         GameObject1 = go1,
         GameObject2 = go2,
         Direction   = SwapDirection.VERTICAL
     };
 }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
        public override void Copy(AGameObject other)
        {
            base.Copy(other);
            var m = other as Mob;

            if (m == null)
            {
                return;                 //!! throw
            }
            Target = m.Target;
        }