public void SetTurnOrder(List <FightingEntity> fighters)
    {
        this.turnOrderHeaderText.gameObject.SetActive(true);
        turnTexts   = new List <BasicText>();
        this.arrows = new List <GameObject>();
        this.index  = 0;
        for (int i = 0; i < fighters.Count; i++)
        {
            FightingEntity fighter          = fighters[i];
            BasicText      instantiatedText = Instantiate <BasicText>(turnTextPrefab);
            instantiatedText.text.SetText(fighter.Name);
            instantiatedText.text.color = fighter.GetOrderColor();



            instantiatedText.transform.SetParent(turnOrderParent);
            turnTexts.Add(instantiatedText);

            if (i != fighters.Count - 1)
            {
                GameObject arrow = Instantiate(arrowPrefab);
                arrow.transform.SetParent(turnOrderParent);
                arrows.Add(arrow);
            }
        }
    }
Exemple #2
0
    public void InstantiateDamageText(double damage, bool isPlayer, Vector3 position, Transform parent = null)
    {
        BasicText textObject = Instantiate(this.damageTextPrefab, parent) as BasicText;

        textObject.transform.position = position;
        textObject.text.text          = Currency.CurrencyToString(damage);
        textObject.text.color         = isPlayer ? textObject.playerColor : textObject.enemyColor;
    }
    public void Initialize()
    {
        texts = new List <BasicText>();
        for (int i = 0; i < maxInstantiatedTexts; i++)
        {
            BasicText newText = Instantiate <BasicText>(textPrefab, queueParent);
            newText.gameObject.SetActive(false);
            texts.Add(newText);
        }

        Messenger.AddListener <string>(Messages.OnPlayerJoinQueue, this.onPlayerJoinQueue);
        Messenger.AddListener(Messages.OnRefreshWaitlistQueueUI, this.RefreshUI);

        this.RefreshUI();
    }
        public CompositionTemplate()
        {
            references = new ReferenceDataComponent();
            var nameText = new BasicText();

            nameText.position = new Vector2(5, 5);
            Register(references);
            var tracker = new PointCollectionTracker <Reference>(references, x =>
            {
                return((TemplateManager.LOADED_TEMPLATES[x.name].GetBoundingBox().Min + TemplateManager.LOADED_TEMPLATES[x.name].GetBoundingBox().Max) / 2 + x.position);
            });

            selector = new Selector <Reference>(new CameraSelectionProvider <Reference>(tracker), x =>
            {
                referenceOutlines[x].boxColor = Color.Orange;
                nameText.text = GetSelectedText(selector.selected);
            }, x =>
            {
                referenceOutlines[x].boxColor = Color.White;
                nameText.text = GetSelectedText(selector.selected);
            });
            Register(selector, nameText);
            RegisterListener(new InputListener(Trigger.E, x =>
            {
                if (selector.selected.Count != 1)
                {
                    return;
                }
                editMode    = true;
                editingItem = TemplateManager.LOADED_TEMPLATES[selector.selected.Single().name];
                editingItem.Focus();
                var listener = new InputListener(Trigger.Escape, y =>
                {
                    editingItem.UnregisterListener(y);
                    this.Focus();
                    RecalculateBoundingBoxes();
                    editingItem = null;
                    editMode    = false;
                });
                editingItem.RegisterListener(listener);
            }));
        }
Exemple #5
0
        public override void Load()
        {
            _sounds = Directory.GetFiles("Assets/SoundPlayer").Where(x => x.Contains(".wav")).Select(x => x.Replace("Assets/", "")).ToArray();

            _uiController = new Controller();
            CenterAnchor centerAnchor = new CenterAnchor();

            _uiController.Add(centerAnchor);

            _controlButton = new BasicButton(Vector3.Zero, new Vector2(36, 36))
            {
                Texture = Context.AssetLoader.Get <Texture>(_playButton),
                OnClick = () =>
                {
                    SoundLayer layer = Context.SoundManager.GetLayer("main");
                    if (layer == null)
                    {
                        return;
                    }

                    if (layer.Status == SoundStatus.Playing)
                    {
                        layer.Pause();
                    }
                    else
                    {
                        layer.Resume();
                    }
                }
            };
            centerAnchor.AddChild(_controlButton, new Rectangle(0, Context.Settings.RenderHeight / 2 - 36, 0, 0));

            BasicButton loopButton = new BasicButton(Vector3.Zero, new Vector2(36, 36))
            {
                Texture = Context.AssetLoader.Get <Texture>(_loopButton)
            };

            loopButton.OnClick = () =>
            {
                SoundLayer layer = Context.SoundManager.GetLayer("main");
                if (layer == null)
                {
                    return;
                }

                layer.Looping   = !layer.Looping;
                loopButton.Tint = layer.Looping ? Color.Green : Color.White;
            };
            centerAnchor.AddChild(loopButton, new Rectangle(-40, Context.Settings.RenderHeight / 2 - 36, 0, 0));

            _soundBar = new ScrollInput(Vector3.Zero, new Vector2(Context.Settings.RenderWidth - 40, 10))
            {
                KeepSelectorInside = true,
                SelectorRatio      = 3
            };
            centerAnchor.AddChild(_soundBar, new Rectangle(0, Context.Settings.RenderHeight / 2 - 10, 0, 0));

            _soundBarInfo = new BasicText(Context.AssetLoader.Get <Font>(_defaultFont), 13, "N/A", Color.White, Vector3.Zero);
            centerAnchor.AddChild(_soundBarInfo, new Rectangle(100, Context.Settings.RenderHeight / 2 - 30, 0, 0));

            CornerAnchor cornerAnchor = new CornerAnchor();

            _uiController.Add(cornerAnchor);

            for (int i = 0; i < _sounds.Length; i++)
            {
                int iCopy = i;

                ClickableLabel addSoundText = new ClickableLabel(Context.AssetLoader.Get <Font>(_defaultFont), 15, _sounds[i], Color.White, Vector3.Zero)
                {
                    OnClick = () =>
                    {
                        if (_append)
                        {
                            Context.SoundManager.PlayQueue(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main");
                        }
                        else
                        {
                            Context.SoundManager.Play(Context.AssetLoader.Get <SoundFile>(_sounds[iCopy]), "main");
                        }
                    }
                };
                cornerAnchor.AddChild(addSoundText, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0));
            }

            BasicButton appendButton = new BasicButton(Vector3.Zero, new Vector2(36, 36))
            {
                Texture = Context.AssetLoader.Get <Texture>(_addButton)
            };

            appendButton.OnClick = () =>
            {
                _append           = !_append;
                appendButton.Tint = _append ? Color.Green : Color.White;
            };
            cornerAnchor.AddChild(appendButton, AnchorLocation.TopLeft, new Rectangle(0, 0, Context.Settings.RenderWidth, 0));

            PlayerVolumeControl volumeControl = new PlayerVolumeControl(Vector3.Zero, new Vector2(100, 20));

            cornerAnchor.AddChild(volumeControl, AnchorLocation.TopRight, new Rectangle(0, 20, 20, 0));
        }