Example #1
0
 /**
  * Adds the graphic to the Entity via a Graphiclist.
  * @param	g		Graphic to add.
  */
 public Graphic AddGraphic(Graphic g)
 {
     if (this.Graphic is Graphiclist)
     {
         (this.Graphic as Graphiclist).Add(g);
     }
     else
     {
         Graphiclist list = new Graphiclist();
         if (this.Graphic)
         {
             list.Add(this.Graphic);
         }
         list.Add(g);
         Graphic = list;
     }
     return(g);
 }
Example #2
0
        /// <summary>
        /// Adds the graphic to the Entity via a Graphiclist.
        /// </summary>
        /// <param name="g">Graphic to add.</param>
        /// <returns>The added Graphic.</returns>
        public Graphic AddGraphic(Graphic g)
        {
            var list = Graphic as Graphiclist;

            if (list != null)
            {
                list.Add(g);
            }
            else
            {
                list = new Graphiclist();
                if (Graphic != null)
                {
                    list.Add(Graphic);
                }

                list.Add(g);
                Graphic = list;
            }

            return(g);
        }
Example #3
0
        public CommandWheel(CommandData[] commands)
        {
            commands = commands?.Where(x => GameEvent.checkDependanciesAndRestrictions(x.Dependancies))?.ToArray();
            if (commands == null)
            {
                //World.Remove(this);
                return;
            }

            this.commands = commands;

            lastMouse = new Point(Mouse.ScreenX, Mouse.ScreenY);

            //Make the wheel
            wheel = new Image(Library.GetTexture("./content/UI/CommandWheel/Wheel.png"));
            wheel.CenterOrigin();

            X = Mouse.ScreenX;
            Y = Mouse.ScreenY;

            Layer = Utility.WHEEL_UI_LAYER;

            AddComponent(wheel);

            //Add commands
            gcommands = new Graphiclist();

            if (this.commands != null && this.commands.Length > 0)
            {
                int deg = -90, deginc = 360 / this.commands.Length;

                foreach (var c in this.commands)
                {
                    Image img = new Image(Library.GetTexture("./content/UI/CommandWheel/" + c.Name + ".png"));
                    img.CenterOrigin();
                    img.Y = -wheel.Height / 2 + img.Height / 2;
                    FP.AngleXY(ref img.X, ref img.Y, deg, wheel.Height / 2 - img.Height / 2);

                    commandImages.Add(c, img);
                    deg += deginc;

                    gcommands.Add(img);
                }
            }

            AddComponent(gcommands);
            ClampHorizontal(0, FP.Width, 100);
            ClampVertical(0, FP.Height, 100);
        }
Example #4
0
        public void AddPlayers(List <Player> players)
        {
            foreach (var p in players)
            {
                var e     = new Entity();
                var lives = new Text(StartingLives.ToString());
                lives.Italicized = true;
                lives.Size       = 18;
                lives.X          = 10;
                lives.Y          = 15;
                lives.ScrollX    = lives.ScrollY = 0;

                var head = new Image(Library.GetTexture("players/" + p.ImageName + "_head.png"));
                head.CenterOO();
                head.X       = -10;
                head.Y       = 25;
                head.ScrollX = head.ScrollY = 0;

                var graphics = new Graphiclist(lives, head);
                graphics.ScrollX = graphics.ScrollY = 0;
                e.AddComponent(graphics);

                if (StartingHealth != 0 && PunchDamage != 0)
                {
                    var health = new Text(string.Format("{0}/{0}", StartingHealth));
                    health.Bold    = true;
                    health.Size    = 18;
                    health.X       = head.X - head.Width / 2;
                    health.Y       = lives.Y + 30;
                    health.ScrollX = health.ScrollY = 0;
                    graphics.Add(health);

                    e.AddResponse(HUD.Message.UpdateDamage, OnDamage(p, health));
                }

                e.AddResponse(Player.Message.Die, OnDeath(p, lives, head));
                e.AddResponse(Player.Message.UpgradeAcquired, OnUpgradeAcquired(p, lives, head));
                e.AddResponse(Upgrade.Message.Used, OnUpgradeUsed());

                Players.Add(e);
                upgradeIcons.Add(new Stack <Image>());
            }
        }