Ejemplo n.º 1
0
        public override void Load()
        {
            players = NetworkManager.Instance.GetPlayerList();
            foreach (Player player in players)
            {
                if (player.ConnectionId == NetworkManager.Instance.myConnId())
                {
                    tank = new TankBuilder(true)
                           .SetChassis(player.Tank.Color_id, player.Tank.Chasis_id)
                           .SetTurret(player.Tank.Chasis_id)
                           .SetTracks(player.Tank.Trucks_id)
                           .Build() as PlayerTank;
                    CreateEntity(tank);
                    tank.transform.SetPosition(new Vector2(player.TankState.Pos_X, player.TankState.Pos_Y));
                    tankDict.Add(player.ConnectionId, tank);
                    if (NetworkManager.Instance.getCurrentPlayer() == "YOU")
                    {
                        tank.StartTurn();
                    }
                }
                else
                {
                    Tank NPCTank = new TankBuilder(false)
                                   .SetChassis(player.Tank.Color_id, player.Tank.Chasis_id)
                                   .SetTurret(player.Tank.Chasis_id)
                                   .SetTracks(player.Tank.Trucks_id)
                                   .Build();
                    CreateEntity(NPCTank);
                    NPCTank.transform.SetPosition(new Vector2(player.TankState.Pos_X, player.TankState.Pos_Y));
                    tankDict.Add(player.ConnectionId, NPCTank);
                }
            }
            //NetworkManager.Instance.GetCrate();

            NetworkManager.Instance.PlayerChanged += Instance_PlayerChanged;


            //background = CreateEntity(new Background()) as Background;

            //terrain = CreateEntity(new Terrain()) as Terrain;

            gameplayUI = CreateEntity(new GameplayUI()) as GameplayUI;
            grenade    = new ProjectileFactory().Create("grenade") as Grenade;
            grenade.transform.SetPosition(new Vector2(300f, 300f));

            crate = CreateEntity(new Crate(Image.FromFile("../../res/crates/crate_0.png"), new Vector2(200f, 200f), grenade, new Vector2(50f, 50f))) as Crate;
            crate.transform.SetPosition(new Vector2(200f, 300f));
            crate.transform.SetSize(new Vector2(50f, 50f));

            /*
             * Tank usaTank = new TankBuilder()
             *  .SetChassis(1, 1)
             *  .SetTurret(1)
             *  .SetTracks(0)
             *  .Build();
             * CreateEntity(usaTank);
             * usaTank.transform.SetPosition(new Vector2(500, 100));
             */
        }
Ejemplo n.º 2
0
        private void Instance_ProjectileExplosion()
        {
            ParticleEmitter particle = new ParticleFactory().Create("explosion") as ParticleEmitter;

            particle.transform.SetPosition(grenade.transform.position);
            particle.Emit();
            grenade.Destroy();
            grenade = null;
        }
Ejemplo n.º 3
0
        public override Entity Create(EntityCreateArgs args)
        {
            Projectile projectile = null;

            switch (args.type.ToLower())
            {
            case "grenade":
                projectile = new Grenade(Image.FromFile("../../res/projectile_grenade.png"), new Vector2(0, 0), 50, 200, 50, 2f);
                break;
            }
            return(SceneManager.Instance.CurrentScene.CreateEntity(projectile));
        }
Ejemplo n.º 4
0
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            currentTime += deltaTime;
            if (grenade != null)
            {
                if (startPositionX == -10)
                {
                    startPositionX = grenade.transform.position.x;
                }
                if (startPositionY == -10)
                {
                    startPositionY = grenade.transform.position.y;
                }

                float lastX = grenade.transform.position.x;
                float lastY = grenade.transform.position.y;
                if (lastY <= 300f)
                {
                    grenade.transform.SetPosition(calculatePos(50f, -9.8f, (float)(50 * (Math.PI / 180.0)), new Vector2(startPositionX, startPositionY), currentTime));
                    //Console.WriteLine(grenade.transform.position.x + " " + grenade.transform.position.y);
                }
                else
                {
                    grenade.Destroy();
                    grenade = null;
                    Console.WriteLine("boom");
                }
            }

            //if (Math.Abs(crate.transform.position.x - tank.transform.position.x) <= (crate.transform.size.x) && Math.Abs(crate.transform.position.y - tank.transform.position.y) <= (crate.transform.size.y))
            //{
            //    crate.Destroy();
            //}
        }
Ejemplo n.º 5
0
 private void Instance_OnShootStart(Vector2 obj)
 {
     grenade = new ProjectileFactory().Create("grenade") as Grenade;
     grenade.transform.SetPosition(obj);
 }