예제 #1
0
 public override Object CreateFromGameMessage(JObject obj, String ownerID)
 {
     Vector2 dir = obj[MSG.DIRECTION.ToString()].ToObject<Vector2>();
     Vector2 pos = obj[MSG.POSITION.ToString()].ToObject<Vector2>();
     RegularMissile missile = new RegularMissile(pos, dir);
     missile.ownerID = ownerID;
     return (Object)(missile);
 }
예제 #2
0
파일: Tank.cs 프로젝트: ollesate/TankGame
        public void Fire()
        {
            if (bulletTimer >= ReloadTime && ammo > 0) {
                bulletTimer = 0;
                ammo--;

                Projectile projectile = null;

                if (BulletType == Projectile.Type.REGULAR) {
                    projectile = new RegularMissile(Position, TurretDirection);
                } else if (BulletType == Projectile.Type.GRENADE) {
                    projectile = new GrenadeMissile(Position, TurretDirection);
                }

                MyController.getInstance().SpawnObject(projectile);

                SmokePuffPuff.AngleGenerator = new Vector2((float)(Calc.AngleOf(TurretDirection) - Math.PI / 6), (float)(Calc.AngleOf(TurretDirection) + Math.PI / 6));
                SmokePuffPuff.newParticleEffect(CenterPosition  + TurretDirection * Size / 2);
                BurnBabyBurn.AngleGenerator = new Vector2((float)(Calc.AngleOf(TurretDirection) - Math.PI / 6), (float)(Calc.AngleOf(TurretDirection) + Math.PI / 6));
                BurnBabyBurn.newParticleEffect(CenterPosition + TurretDirection * Size / 2);

            }
        }
예제 #3
0
    private void recieveGameMessage(String json)
    {
        JObject obj = JObject.Parse(json);
        if (obj[KEY_MSG_TYPE].ToString() == MSG_TYPE.SPAWN.ToString()) {

            String cls = obj[KEY_OBJECT_TYPE].ToString();
            OnlineObject spawnedObj;

            Console.WriteLine("Game Server Spawn " + cls);

            if (cls == ClassNames.RegularMissile) {

                spawnedObj = new RegularMissile(Vector2.Zero, Vector2.Zero).CreateFromGameMessage(
                                obj[KEY_JOBJECT].ToObject<JObject>(),
                                obj[KEY_OWNER].ToString())
                                as OnlineObject;

                addInGameObject((RegularMissile)(spawnedObj));

            }

        }
        else if (obj[KEY_MSG_TYPE].ToString() == MSG_TYPE.UPDATE.ToString()) {

            String cls = obj[KEY_OBJECT_TYPE].ToString();

            if (cls == ClassNames.TanksGame) {

                tankGame.OnlineUpdate(
                    obj[KEY_JOBJECT].ToObject<JObject>(),
                    obj[KEY_OWNER].ToString());

            }

        }
    }