コード例 #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);
            }
        }
コード例 #2
0
 public void Draw(Graphics graph, AGameObject gameObject)
 {
     if (gameObject is AFish)
     {
         Draw(graph, (AFish)gameObject);
     }
 }
コード例 #3
0
ファイル: TurretGun.cs プロジェクト: graph-di5/sky-shoot
 public TurretGun(Guid id, Vector2 parentTurretCoordinates, AGameObject owner = null)
     : base(id, owner)
 {
     WeaponType  = WeaponType.TurretGun;
     ReloadSpeed = Constants.TURRET_GUN_ATTACK_RATE;
     this._parentTurretCoordinates = parentTurretCoordinates;
 }
コード例 #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);
         }
     }
 }
コード例 #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);
        }
コード例 #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;
                }
            }
        }
コード例 #7
0
 public DrawableGameObject(AGameObject other, Animation2D animation)
 {
     Animation = animation;
     Animation.Initialize(FRAME_TIME, LOOPING);
     Copy(other);
     MakeOriginalRadius();
 }
コード例 #8
0
 public Shotgun(Guid id, AGameObject owner = null)
     : base(id, owner)
 {
     _rand       = new Random();
     WeaponType  = WeaponType.Shotgun;
     ReloadSpeed = Constants.SHOTGUN_ATTACK_RATE;
 }
コード例 #9
0
ファイル: PoisonBullet.cs プロジェクト: graph-di5/sky-shoot
        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);
        }
コード例 #10
0
 public DrawableGameObject(AGameObject other, Texture2D staticTexture)
 {
     Animation     = null;
     StaticTexture = staticTexture;
     Copy(other);
     MakeOriginalRadius();
 }
コード例 #11
0
        public static AGameObject OneObject(AGameObject gameObject)
        {
            var gameObjectCopy = new AGameObject();

            gameObjectCopy.Copy(gameObject);
            return(gameObjectCopy);
        }
コード例 #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");
                }
            }
        }
コード例 #13
0
        public static AGameObject OneObject(AGameObject m)
        {
            var o = new AGameObject();

            o.Copy(m);
            return(o);
        }
コード例 #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;
 }
コード例 #15
0
ファイル: PistolBullet.cs プロジェクト: graph-di5/sky-shoot
 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;
 }
コード例 #16
0
 protected void SomebodyMoved(AGameObject sender, Vector2 direction)
 {
     sender.RunVector = direction;
     lock (_gameObjects)
     {
         PushEvent(new ObjectDirectionChanged(direction, sender.Id, _timeHelper.GetTime()));
     }
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #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;
 }
コード例 #20
0
        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);
        }
コード例 #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);
        }
コード例 #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;
 }
コード例 #23
0
ファイル: Piranha.cs プロジェクト: SanGreen74/AquariumWork
 public override void OnCollision(AGameObject anotherObject)
 {
     if (anotherObject != Victim)
     {
         return;
     }
     Victim.Die();
     Victim = null;
 }
コード例 #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;
 }
コード例 #25
0
ファイル: SwordsMan.cs プロジェクト: SanGreen74/AquariumWork
 public override void OnCollision(AGameObject anotherObject)
 {
     if (anotherObject != Victim || State != FishState.Attack)
     {
         return;
     }
     Victim.Die();
     Victim = null;
 }
コード例 #26
0
ファイル: Flame.cs プロジェクト: graph-di5/sky-shoot
 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;
 }
コード例 #27
0
 public void ClientSwapH(AGameObject go1, AGameObject go2)
 {
     GameMatrix.SwapH(go1, go2);
     clientSwapModel = new SwapModel
     {
         GameObject1 = go1,
         GameObject2 = go2,
         Direction   = SwapDirection.HORIZONTAL
     };
 }
コード例 #28
0
 public void ClientSwapV(AGameObject go1, AGameObject go2)
 {
     GameMatrix.SwapV(go1, go2);
     clientSwapModel = new SwapModel
     {
         GameObject1 = go1,
         GameObject2 = go2,
         Direction   = SwapDirection.VERTICAL
     };
 }
コード例 #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);
        }
コード例 #30
0
ファイル: Mob.cs プロジェクト: graph-di5/sky-shoot
        public override void Copy(AGameObject other)
        {
            base.Copy(other);
            var m = other as Mob;

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