コード例 #1
0
        // Constructors =======================================//
        public Hud(GameScreen parent)
            : base(parent)
        {
            // Initialize Fields
            maxDamage = 100f;
            damageValue = 100f;
            resistanceValue = 100f;
            scoreValue = GlobalVariables.score;
            moneyValue = GlobalVariables.money;

            hudSprite = Engine.Content.Load<Texture2D>("Content\\Textures\\damage");
            SpriteFont font1 = Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24");

            // Initialize the Damage bars
            damageText = new Entity2D(hudSprite, new Vector2(15f, 30f), this.Parent);
            damageText.Rectangle = new Rectangle(0, 150, 260, 50);

            damageBox = new Entity2D(hudSprite, new Vector2(10f, 10f), this.Parent);
            damageBox.Rectangle = new Rectangle(0, 0, 260, 50);

            damageBarGlass = new Entity2D(hudSprite, new Vector2(10f, 20f), this.Parent);
            damageBarGlass.Rectangle = new Rectangle(0, 50, 260, 50);

            damageBar = new Entity2D(hudSprite, new Vector2(20f, 20f), this.Parent);
            damageBar.Rectangle = new Rectangle(0, 100, 238, 50);

            // Initialize the text
            Vector2 bgHudPos = new Vector2(0, Engine.Viewport.Height - 90);

            levelText = new EntityText(font1, new Vector2(10, 11), "Level:"+GlobalVariables.level.ToString(), this.Parent);
            levelText.Position = new Vector2(Engine.Viewport.Width-120, bgHudPos.Y + 15);

            scoreText = new EntityText(font1, new Vector2(10, 11), GlobalVariables.score.ToString(), this.Parent);
            scoreText.Position = new Vector2(230, bgHudPos.Y + 15);

            moneyText = new EntityText(font1, new Vector2(10, 35), GlobalVariables.money.ToString(), this.Parent);
            moneyText.Position = new Vector2(530, bgHudPos.Y + 15);

            hudSprite = Engine.Content.Load<Texture2D>("Content\\Textures\\moneyHUD");

            // Initialize the score and money fields
            scoreGlass = new Entity2D(hudSprite, new Vector2(10, bgHudPos.Y), this.Parent);
            scoreGlass.Rectangle = new Rectangle(0, 200, 300, 100);

            moneyGlass = new Entity2D(hudSprite, new Vector2(300, bgHudPos.Y), this.Parent);
            moneyGlass.Rectangle = new Rectangle(0, 200, 300, 100);

            score = new Entity2D(hudSprite, new Vector2(10, bgHudPos.Y), this.Parent);
            score.Rectangle = new Rectangle(0, 0, 300, 100);

            money = new Entity2D(hudSprite, new Vector2(300, bgHudPos.Y), this.Parent);
            money.Rectangle = new Rectangle(0, 100, 300, 100);

            // Initialize the black Texture
            black = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                    new Vector2(0, 400), this.Parent);
            black.Rectangle = new Rectangle(0, 0, 800, 75);
            black.Position = bgHudPos;
            black.Alpha = 0.3f;
        }
コード例 #2
0
    public void LoadDialogueFromJson()
    {
        _entityText = GetComponent <EntityText>();

        if (TryDownloadingBlob)
        {
            StartCoroutine(DownloadBlob());
        }

        // First: Is the downloaded blob empty?  If so, use a local data file.
        if (string.IsNullOrEmpty(RawBlob))
        {
            RawBlob = FetchLocalBlob();

            // Second: Is the local data file empty?  If so, don't go any further,
            //         because this is a waste of time.
            if (string.IsNullOrEmpty(RawBlob))
            {
                return;
            }
            else
            {
                _entityText.MapBlob(RawBlob);
            }
        }
        else
        {
            _entityText.MapBlob(RawBlob);
        }
    }
コード例 #3
0
        // Initializor=============================================
        public override void Initialize()
        {
            // Initialize the keyboard
            keyboard = Engine.Services.GetService<KeyboardDevice>();
            mouseDevice = Engine.Services.GetService<MouseDevice>();
            mouseDevice.ResetMouseAfterUpdate = false;

            // Initialize buttons
            Texture2D texture;

            hand = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\hand"),
                    new Vector2(mouseDevice.State.X, mouseDevice.State.Y), this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuReturnBtn");
            returnBtn = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 270), this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuMenuBtn");
            menuBtn = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 320), this);

            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\menuQuitBtn");
            quitBtn = new Button(texture, new Vector2((Engine.Viewport.Width / 2) - (texture.Width / 2), 370), this);

            pauseText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"),
                new Vector2((Engine.Viewport.Width / 2)-40, 200), "PAUSE", this);

            // Initialize the black texture
            black = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                    Vector2.Zero, this);
            black.Alpha = 0.4f;

            base.Initialize();
        }
コード例 #4
0
        public int sizeOfText(EntityText textEntity)
        {
            // The width of each character in the spriteFont
            int charWidth = 13;

            // return the size of the text
            return charWidth * textEntity.Text.Length;
        }
コード例 #5
0
    public override void Start()
    {
        base.Start();

        _entityText         = GetComponent <EntityText>();
        _controlManager     = ControlManager.Instance;
        _dialogueController = DialogueController.Instance;
    }
コード例 #6
0
	public override void Start()
	{
		base.Start();

		_entityText = GetComponent<EntityText>();
		_controlManager = ControlManager.Instance;
		_dialogueController = DialogueController.Instance;
	}
コード例 #7
0
        // Initializor=============================================
        public override void Initialize()
        {
            // Initialize the keyboard
            keyboard = Engine.Services.GetService<KeyboardDevice>();
            mouseDevice = Engine.Services.GetService<MouseDevice>();
            mouseDevice.ResetMouseAfterUpdate = false;

            Texture2D texture;
            Texture2D level_finish_bg=Engine.Content.Load<Texture2D>("Content\\Textures\\level_finish_bg");

            hand = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\hand"),
                    new Vector2(mouseDevice.State.X, mouseDevice.State.Y), this);

            // Initialize the Game Text
            string level="LEVEL " + GlobalVariables.level.ToString() + " COMPLETE";
            titleText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"),
                new Vector2((Engine.Viewport.Width / 2) - 20, 200), level, this);

            string score = "Score: " + GlobalVariables.score.ToString()+" points.";
            scoreText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"),
                new Vector2((Engine.Viewport.Width / 2) - 120, 270), score, this);

            string money = "Money: " + GlobalVariables.money.ToString() + " Dirhams";
            moneyText = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24"),
                new Vector2((Engine.Viewport.Width / 2) - 120, 330), money, this);

            // Initialize the black texture
            texture = Engine.Content.Load<Texture2D>("Content\\Textures\\next_btn");
            nextBtn = new Button(texture, new Vector2(475, 380), this);

            background = new Entity2D(level_finish_bg,
                                Vector2.Zero, this);
            background.Alpha = 0f;
            background.Position = new Vector2((Engine.Viewport.Width / 2) - (background.Texture.Width / 2),
                                             (Engine.Viewport.Height / 2) - (background.Texture.Height / 2));

            fade = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\black"),
                    Vector2.Zero, this);
            fade.Alpha = 0.4f;

            base.Initialize();
        }
コード例 #8
0
 private void GetEntityName()
 {
     if (!string.IsNullOrEmpty(EntityText))
     {
         foreach (string line in EntityText.Split('\n'))
         {
             if (line.TrimStart().StartsWith("public") && line.Contains("class"))
             {
                 string[] stats = line.Trim().Split(' ');
                 for (int i = 0; i < stats.Length - 1; i++)
                 {
                     if (stats[i] == "class")
                     {
                         EntityName = stats[i + 1];
                         OnPropertyChanged("EntityName");
                     }
                 }
             }
         }
     }
 }
コード例 #9
0
	public void LoadDialogueFromJson()
	{
		_entityText = GetComponent<EntityText>();

		if(TryDownloadingBlob)
			StartCoroutine(DownloadBlob());
		
		// First: Is the downloaded blob empty?  If so, use a local data file.
		if(string.IsNullOrEmpty(RawBlob))
		{
			RawBlob = FetchLocalBlob();
			
			// Second: Is the local data file empty?  If so, don't go any further,
			//         because this is a waste of time.
			if(string.IsNullOrEmpty(RawBlob))
				return;
			else
				_entityText.MapBlob(RawBlob);
		}
		else
		{
			_entityText.MapBlob(RawBlob);
		}
	}
コード例 #10
0
        private void GenerateAdapter_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(EntityText))
            {
                StringBuilder sbAdapterFinal = new StringBuilder();
                sbAdapterFinal.AppendLine();
                sbAdapterFinal.AppendLine("#region Entity properties");
                sbAdapterFinal.AppendLine();
                StringBuilder sbAdapter;

                StringBuilder sbDeepCopy = new StringBuilder();

                StringBuilder sbMaintain = new StringBuilder();

                StringBuilder sbPropertyChanged = new StringBuilder();

                foreach (string line in EntityText.Split('\n'))
                {
                    //find out all Resx tags
                    if (line.TrimStart().StartsWith("public") && !line.Contains(" class "))
                    {
                        string[] stats = line.Trim().Split(' ');
                        if (stats.Length == 3)
                        {
                            sbAdapter = new StringBuilder();
                            //public string FlightNumber
                            sbAdapter.Append(stats[0] + " ");
                            if (stats[1] == "String ")
                            {
                                sbAdapter.Append("string ");
                            }
                            else
                            {
                                sbAdapter.Append(stats[1] + " ");
                            }
                            sbAdapter.Append(stats[2]);
                            sbAdapter.AppendLine();

                            //{
                            sbAdapter.AppendLine("{");
                            //    get { return Flight.FlightNumber; }
                            sbAdapter.AppendLine("    get { return " + EntityName + "." + stats[2] + ";}");

                            //}
                            sbAdapterFinal.AppendLine("}");
                            sbAdapterFinal.AppendLine();

                            // Deep copy
                            // target.Code = source.Code;
                            sbDeepCopy.AppendLine("target." + stats[2] + " = " + "source." + stats[2] + ";");

                            sbAdapterFinal.Append(sbAdapter);

                            //set
                            //{
                            //    if (value != group.Name)
                            //    {
                            //        group.Name = value;
                            //        RaisePropertyChangedEvent("Name");
                            //    }
                            //}
                            sbAdapter.AppendLine("    set {");
                            sbAdapter.AppendLine("        if (value != " + EntityName + "." + stats[2] + ")");
                            sbAdapter.AppendLine("        {");
                            sbAdapter.AppendLine("            " + EntityName + "." + stats[2] + " = value;");
                            sbAdapter.AppendLine("            RaisePropertyChangedEvent(\"" + stats[2] + "\");");
                            sbAdapter.AppendLine("        }}");
                            sbAdapter.AppendLine("    }");

                            sbMaintain.Append(sbAdapter);

                            // case "Resource":
                            // RaisePropertyChangedEvent("Stand");
                            // break;
                            sbPropertyChanged.AppendLine("case \"" + stats[2] + "\" :");
                            sbPropertyChanged.AppendLine("  RaisePropertyChangedEvent(\"" + stats[2] + "\" );");
                            sbPropertyChanged.AppendLine("  break;");
                        }
                    }
                }

                sbAdapterFinal.AppendLine();
                sbAdapterFinal.AppendLine("#endregion");


                AdapterText = sbAdapterFinal.ToString();
                OnPropertyChanged("AdapterText");

                CopyText = sbDeepCopy.ToString();
                OnPropertyChanged("CopyText");

                MaintainText = sbMaintain.ToString();
                OnPropertyChanged("MaintainText");

                PropertyChangedText = sbPropertyChanged.ToString();
                OnPropertyChanged("PropertyChangedText");
            }
        }
コード例 #11
0
        protected override void Setup(Model Model, Vector3 Position)
        {
            base.Setup(Model, Position);
            this.Scale = new Vector3(0.125f / 1.3f);
            this.Position += new Vector3(0f, 2f, 0f);
            this.defaultLightingEnabled = true;
            releaseType = ReleaseType.Danger;

            text = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24Or"),
                    GraphicsUtil.GetProjectPoint(Position), "Good !", this.Parent);
            text.Visible = false;
        }
コード例 #12
0
    public void PresentEntityText(EntityText entityText)
    {
        TextThread thread = entityText.GetCurrentTextThread();

        PresentTextThread(thread);
    }
コード例 #13
0
    private void AcquireTextFromAvailableEntities()
    {
        if (_textProviders == null ||
            _textProviders.Length == 0)
        {
            return;
        }

        EntityText availableEntity = _textProviders.FirstOrDefault(t => t.CanTalk == true);

        if (DebugMode)
        {
            Debug.Log("There is " + (availableEntity == default(EntityText) ? "no" : "an") + " NPC that can talk.");
        }

        // Code Case: We no longer have an entity, but we still show there being dialogue.
        // User Case: Player has left a trigger with text still shown.
        // Desired Result: Stop showing text, reset line counter.
        if (availableEntity == default(EntityText) &&
            DialogueAvailable)
        {
            if (DebugMode)
            {
                Debug.Log("User has left a text trigger, so hide text.");
            }

            _currentThread.ResetIndex();
            DialogueAvailable = false;
            HideElements();
        }
        // Code Case: We have an entity, and we do not see any current dialogue.
        // User Case: Player has initiated a conversation sequence.
        // Desired Result: Start showing text, set line counter to first item, set speaker name.
        //                 Also, lock the player's player control script.
        else if (availableEntity != default(EntityText) &&
                 (!DialogueAvailable))
        {
            if (DebugMode)
            {
                Debug.Log("Player has initiated a conversation.");
            }

            _currentThread = availableEntity.CurrentThread(_ambassador.SequenceCounters);
            _currentThread.ResetIndex();

            DialogueText currentText = _currentThread.GetCurrentText();
            if (currentText != null)
            {
                PresentLine(currentText);
                DialogueAvailable = true;

                PlayerHasControl(false);
                ShowElements();
            }
        }

        // Code Case: We have both an entity and show dialogue
        // User Case: An conversation is on-going
        // Desired Result: Do not mess with it!

        // Code Case: We have no entity and show no dialogue [Default State]
        // User Case: User is doing some non-conversation activity
        // Desired Result: Do nothing.
    }
コード例 #14
0
        protected override void Setup(Model Model, Vector3 Position)
        {
            base.Setup(Model, Position);
            shadow.Scale += new Vector3(0.5f, 0f, 0f);
            Alpha = 1f;
            this.Position += new Vector3(0f, 2f, 0f);
            this.defaultLightingEnabled = true;
            this.Scale = new Vector3(1f,1f,2f);
            releaseType = ReleaseType.Money;

            icon = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\moneyIcon"),
                                GraphicsUtil.GetProjectPoint(Position), this.Parent);
            icon.Visible = false;

            text = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24Or"),
                                GraphicsUtil.GetProjectPoint(Position), "Money !", this.Parent);
            text.Visible = false;
        }
コード例 #15
0
        protected override void Setup(Model Model, Vector3 Position)
        {
            base.Setup(Model, Position);
            this.Scale = new Vector3(0.125f / 1.3f);
            this.defaultLightingEnabled = true;
            this.Position += new Vector3(0f, 2f, 0f);
            releaseType = ReleaseType.Normal;

            icon = new Entity2D(Engine.Content.Load<Texture2D>("Content\\Textures\\scoresIcon"),
                    GraphicsUtil.GetProjectPoint(Position), this.Parent);
            icon.Visible = false;

            text = new EntityText(Engine.Content.Load<SpriteFont>("Content\\Fonts\\FontAgency24Or"),
                                GraphicsUtil.GetProjectPoint(Position), "+100", this.Parent);
            text.Visible = false;
        }