Beispiel #1
0
        public void MergeWith(Collector other)
        {
            poofAnim.Play(0);
            Audio.Play("collector.merge", display);

            OrderedDictionary o = new OrderedDictionary();

            o.Add("team_1", id);
            o.Add("team_2", other.id);
            EventManager.Emit("collector:merge", o);

            capacity      += (int)(other.capacity * 0.5);
            collected     += (int)(other.collected * 0.5);
            collectRadius += (int)(other.collectRadius * 0.5f);
            targetScale   += (other.scale * 0.3f);
            numCollectors += other.numCollectors;

            foreach (User u in other.users)
            {
                u.collector = this;
                users.Add(u);
            }

            health = 100;

            TeamColour.Put(other.teamColour);
            CollectorManager.Remove(other);
        }
Beispiel #2
0
        public User(string user, int userId, int teamId, int inDisplay) : base()
        {
            delta     = Vector2.Zero;
            username  = user;
            id        = userId;
            display   = inDisplay;
            scale     = 1.0f;
            dampening = 0.8f;
            maxSpeed  = 20f;
            action    = (int)Actions.Idling;

            spriteBatch = ScreenManager.spriteBatch;
            collector   = CollectorManager.CollectorByID(teamId);
            collector.AddUser(this);

            pointsNotification = new Notification(2.5f);
            badgeNotification  = new Notification(3f);
            pointsAbsorbDelay  = new Durationizer(0.5f);

            usernameFont   = ContentManager.Font("user_name");
            userpointsFont = ContentManager.Font("user_points");
            teamRing       = ContentManager.Sprite("user_team");

            SetupOffsets();
            SetupAnimations();

            Audio.Play("user.spawn", display);
        }
Beispiel #3
0
        protected override void Initialize()
        {
            ScreenManager.Initialize(this, graphics.GraphicsDevice);

            ContentManager.Initialize(this);
            EventManager.Initialize();
            GridManager.Initialize(10);
            Audio.Initialize();
            server = new Server();

            worldManager           = new WorldManager(this);
            worldManager.DrawOrder = 1;
            Components.Add(worldManager);

            resourceManager           = new ResourceManager(this, worldManager);
            resourceManager.DrawOrder = 2;
            Components.Add(resourceManager);

            wormholeManager           = new WormholeManager(this);
            wormholeManager.DrawOrder = 3;
            Components.Add(wormholeManager);

            collectorManager           = new CollectorManager(this);
            collectorManager.DrawOrder = 4;
            Components.Add(collectorManager);

            enemyManager           = new EnemyManager(this);
            enemyManager.DrawOrder = 5;
            Components.Add(enemyManager);

            userManager           = new UserManager(this);
            userManager.DrawOrder = 6;
            Components.Add(userManager);

            TeamColour.Initialize();
            VLine.Effect = new BasicEffect(GraphicsDevice);

            beautyPass   = ContentManager.Shader("BeautyRender");
            noiseTexture = Content.Load <Texture2D>(@"images/noise");
            beautyPass.CurrentTechnique = beautyPass.Techniques["Pretty"];
            beautyPass.Parameters["TextureSize"].SetValue(ScreenManager.window);
            beautyPass.Parameters["NoiseMap"].SetValue(noiseTexture);

            oldState    = Keyboard.GetState();
            spriteBatch = new SpriteBatch(GraphicsDevice);

            for (int i = 0; i < 4; i++)
            {
                tmpTargets[i] = new RenderTarget2D(ScreenManager.graphics, 1280, 800, false,
                                                   ScreenManager.graphics.PresentationParameters.BackBufferFormat,
                                                   DepthFormat.Depth24, 8, RenderTargetUsage.PreserveContents);
            }

            base.Initialize();
        }
Beispiel #4
0
        public void PortalDie()
        {
            if (!isDying)
            {
                Die();

                portalAnim.WhenFinished(() => {
                    TeamColour.Put(teamColour);
                    CollectorManager.Remove(this);
                });

                collectorAnim.Play((int)States.Outro1 + damage);
                portalAnim.Play(0);
            }
        }
Beispiel #5
0
        public void ExplodeDie()
        {
            if (!isDying)
            {
                Die();

                explodeAnim.WhenFinished(() => {
                    TeamColour.Put(teamColour);
                    CollectorManager.Remove(this);
                });

                Audio.Play("collector.bass", 4);
                collectorAnim.Play((int)States.Exploding);
                collectorAnim.frameOffset = new Vector2(50, 137);
                explodeAnim.Play(0);
            }
        }
Beispiel #6
0
        public override void Initialize()
        {
            users = new List <User>();

            EventManager.On("user:new", (o) =>
            {
                int id      = (int)o["id"];
                int teamId  = (int)o["teamId"];
                int display = (int)o["display"];
                users.Add(new User((string)o["username"], id, teamId, display));
            });

            EventManager.On("user:disconnect", (o) =>
            {
                int id   = (int)o["id"];
                var user = users.FirstOrDefault(u => u.id == id);

                if (user != null)
                {
                    user.Disconnect();
                }
            });

            EventManager.On("user:getPoints", (o) =>
            {
                User user = UserByID((int)o["id"]);
                if (user != null)
                {
                    user.GetPoints((int)o["value"]);
                }
            });

            EventManager.On("user:getBadge", (o) =>
            {
                User user = UserByID((int)o["id"]);
                if (user != null)
                {
                    user.GetBadge((string)o["type"]);
                }
            });

            EventManager.On("user:touch", (o) =>
            {
                User user = UserByID((int)o["id"]);
                if (user != null)
                {
                    user.SetDelta((int)o["x"], (int)o["y"]);
                }
            });

            EventManager.On("user:touchEnd", (o) =>
            {
                User user = UserByID((int)o["id"]);
                if (user != null)
                {
                    user.SetDelta(0, 0);
                }
            });

            EventManager.On("user:bloat", (o) =>
            {
                User user = UserByID((int)o["id"]);
                if (user != null)
                {
                    user.BloatStart();
                }
            });

            EventManager.On("user:pinch", (o) =>
            {
                User user = UserByID((int)o["id"]);
                if (user != null)
                {
                    user.PinchStart();
                }
            });

            EventManager.On("user:bloatEnd", (o) =>
            {
                User user = UserByID((int)o["id"]);
                if (user != null)
                {
                    user.BloatEnd();
                }
            });

            EventManager.On("user:pinchEnd", (o) =>
            {
                User user = UserByID((int)o["id"]);
                if (user != null)
                {
                    user.PinchEnd();
                }
            });

            EventManager.On("user:newTeam", (o) =>
            {
                User user = UserByID((int)o["id"]);
                if (user != null)
                {
                    user.collector = CollectorManager.CollectorByID((int)o["teamId"]);
                }
            });

            base.Initialize();
        }
Beispiel #7
0
 protected void CheckCollision()
 {
     CollectorManager.CheckEnemyCollide(this);
 }
Beispiel #8
0
 public CollectorManager(Game game) : base(game)
 {
     CollectorManager.instance = this;
 }