示例#1
0
        public void PlacePlayer(Player player)
        {
            Random random  = new Random();
            int    _placed = 0;

            do
            {
                int _randX = random.Next(0, MapSizeX);
                int _randY = random.Next(0, MapSizeY);

                Tile CurrentTile = (Tile)GameMap[_randX, _randY];
                bool _iswalkable = CurrentTile.IsWalkable;
                bool _ishallway  = CurrentTile.IsHallway;

                if (_iswalkable && _placed == 0 && !_ishallway)
                {
                    CurrentTile.Icon       = PlayerIcon;
                    CurrentTile.IsWalkable = false;

                    player.X = _randX;
                    player.Y = _randY;
                    _placed  = 1;
                }
            } while (_placed == 0);

            StatBar.Display(player);
        }
示例#2
0
    public IEnumerator FunctionalRequirements_HealthBarShouldBeVisibleAboveAllEntities()
    {
        GameObject magePlayer   = Object.Instantiate(TestResourceManager.Instance.GetResource("Mage Player"), Vector3.zero, Quaternion.identity);
        GameObject meleePlayer  = Object.Instantiate(TestResourceManager.Instance.GetResource("Melee Player"), Vector3.zero, Quaternion.identity);
        GameObject healerPlayer = Object.Instantiate(TestResourceManager.Instance.GetResource("Healer Player"), Vector3.zero, Quaternion.identity);
        GameObject rangedPlayer = Object.Instantiate(TestResourceManager.Instance.GetResource("Ranged Player"), Vector3.zero, Quaternion.identity);
        GameObject enemy        = Object.Instantiate(TestResourceManager.Instance.GetResource("Enemy"), Vector3.zero, Quaternion.identity);

        magePlayer.transform.position   = new Vector3(-4, 0, -2);
        meleePlayer.transform.position  = new Vector3(-2, 0, -2);
        healerPlayer.transform.position = new Vector3(0, 0, -2);
        rangedPlayer.transform.position = new Vector3(2, 0, -2);
        enemy.transform.Rotate(new Vector3(0, 1, 0), 180);

        yield return(new WaitForEndOfFrame());

        EntityStatsController[] entities = Object.FindObjectsOfType <EntityStatsController>();
        foreach (EntityStatsController entity in entities)
        {
            StatBar bar = entity.GetComponentInChildren <StatBar>();
            Assert.IsNotNull(bar, "Health bar was not found on " + entity.gameObject.name);
        }

        yield return(null);
    }
示例#3
0
 void Start()
 {
     RedStatBar   = new StatBar(this.Endurance + this.CombatSkill + this.WillPower);
     BlueStatBar  = new StatBar(this.Agility + this.Dexterity + this.Cunning);
     GreenStatBar = new StatBar(this.Intelligence + this.Wisdom + this.Talent);
     GreyStatBar  = new StatBar(15);
     Total        = new StatBar(RedStatBar.MaxValue + BlueStatBar.MaxValue + GreenStatBar.MaxValue + GreyStatBar.MaxValue);
 }
 void Start()
 {
     adrenaline = gameObject.AddComponent<StatBar>();
     adrenaline.Setup(100, 100, "Adrenaline");
     health = gameObject.AddComponent<StatBar>();
     health.Setup(100, 100, "Health");
     aggression = gameObject.AddComponent<StatBar>();
     aggression.Setup(100, 0, "Aggression");
 }
示例#5
0
 public void PeriodicallyChangeStatBar(StatBar statBar, float time, float quantity)
 {
     FunctionPeriodic.Create(() =>
     {
         if (statBar.GetValue() > 0f)
         {
             statBar.AddValue(quantity);
         }
     }, time);
 }
示例#6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            player = new Jedi(new Vector2(100, 100));
            player.LoadContent(Content);
            healthBar = new StatBar(new Vector2(200, 200), new Rectangle());
            healthBar.LoadContent(Content, "Graphics/healthBar");
        }
示例#7
0
 public void NextTileIsWalkable(Tile CurrentTile, Tile NextTile, Player player, string _direction)
 {
     CurrentTile.Icon       = FloorIcon;
     CurrentTile.IsWalkable = true;
     NextTile.Icon          = PlayerIcon;
     NextTile.IsWalkable    = false;
     player.X = NextTile.X;
     player.Y = NextTile.Y;
     StatBar.Display(player);
     ActivityLog.AddToLog("You move " + _direction + ".");
 }
示例#8
0
 void Start()
 {
     Tracker         = FindObjectOfType <ManagerTracker>();
     TheText         = GetComponent <Text>();
     TheImage        = GetComponent <Image>();
     TheMeshRenderer = GetComponent <MeshRenderer>();
     TheStatBar      = GetComponent <StatBar>();
     if (TheText != null)
     {
         PreviousColor = TheText.color;
     }
 }
示例#9
0
        public Hunter(PlayerIndex index, Texture2D backTexture, Texture2D frontTexture, int health, string damageSound, int air, Sprite sprite, uint collisionDamage, float speed, Texture2D bulletTexture, string shotSound, Vector2 shotOffset, int bulletHits, uint bulletDamage, float bulletSpeed, float shotTime)
            : base(index, backTexture, frontTexture, health, damageSound, sprite, collisionDamage, speed, true, true, bulletTexture, shotOffset, bulletHits, bulletDamage, bulletSpeed, shotTime)
        {
            this.air = new StatBar(air);
            if (air == 0)
            {
                airEnabled = false;
            }

            this.shotSound = shotSound;

            invTime = 0.4f;
        }
示例#10
0
 // Start is called before the first frame update
 void Start()
 {
     hpBar       = new StatBar("hpBar");
     hpBar.width = transform.GetChild(1).gameObject.GetComponent <RectTransform>().rect.width;
     hpBar.panel = transform.GetChild(1).GetChild(0).gameObject.GetComponent <RectTransform>();
     hpBar.text  = transform.GetChild(1).GetChild(1).gameObject.GetComponent <Text>();
     spBar       = new StatBar("spBar");
     spBar.width = transform.GetChild(2).gameObject.GetComponent <RectTransform>().rect.width;
     spBar.panel = transform.GetChild(2).GetChild(0).gameObject.GetComponent <RectTransform>();
     spBar.text  = transform.GetChild(2).GetChild(1).gameObject.GetComponent <Text>();
     // 이벤트 리스너 지정.
     EventListener.GetEventListener().Binding("PlayInfoManager", "ChangeData", "MenuUI/Sync : ");
     Sync();
 }
示例#11
0
            public HUD(Camera c, int i, int numTeams, bool canDrawScores)
            {
                myCamera = c;

                shouldDrawScores = canDrawScores;

                Vector2 safeAreaStart = new Vector2((i / 2 == 0) ? c.GetPort().TitleSafeArea.Left : 0, (i % 2 == 0) ? c.GetPort().TitleSafeArea.Top : 0);
                Vector2 safeAreaEnd   = new Vector2(((i / 2 == 0) ? c.GetPort().TitleSafeArea.Left : 0) + c.GetPort().TitleSafeArea.Width, (i % 2 == 0) ? c.GetPort().TitleSafeArea.Top : 0);

                leftPos  = safeAreaStart + new Vector2(150, 50);
                rightPos = ((shouldDrawScores) ? safeAreaEnd + new Vector2(-24 + (4 - Math.Min(numTeams, 4)) * 82, 50) : Level.DEFAUT_SCREEN_SIZE / 2 + new Vector2(364.0f, -16.0f));

                if (c.commanderType == typeof(RedCommander) || c.commanderType == typeof(RedPlayerCommander))
                {
                    front = new Sprite("HUD/hud_red", leftPos);
                }
                else if (c.commanderType == typeof(BlueCommander) || c.commanderType == typeof(BluePlayerCommander))
                {
                    front = new Sprite("HUD/hud_blue", leftPos);
                }
                else if (c.commanderType == typeof(GreenCommander) || c.commanderType == typeof(GreenPlayerCommander))
                {
                    front = new Sprite("HUD/hud_green", leftPos);
                }
                else if (c.commanderType == typeof(YellowCommander) || c.commanderType == typeof(YellowPlayerCommander))
                {
                    front = new Sprite("HUD/hud_yellow", leftPos);
                }

                //Set up other sprites
                back       = new Sprite("HUD/hud_background", leftPos);
                damage     = new StatBar("HUD/bar_damage", leftPos + new Vector2(39, -13));
                health     = new StatBar("HUD/bar_health", leftPos + new Vector2(39, -13));
                power      = new StatBar("HUD/bar_special", leftPos + new Vector2(18, 11));
                gun        = new Sprite("HUD/hud_gun", leftPos + new Vector2(-82, 0));
                toss       = new Sprite("HUD/hud_toss", leftPos + new Vector2(-47, -8));
                teammate   = new Sprite("HUD/hud_teammates", leftPos + new Vector2(86, 11));
                scoreboard = new Sprite("HUD/hud_score_frame", rightPos - new Vector2(180, -10));
                timer      = new Sprite("HUD/hud_time_frame", rightPos - new Vector2(440, -7));

                lastScores       = new int[numTeams];
                lastScoreStrings = new string[numTeams];

                for (int t = 0; t < numTeams; t++)
                {
                    lastScores[t]       = 0;
                    lastScoreStrings[t] = "" + lastScores[t];
                }
            }
示例#12
0
        public void DrawEnemyStats(Enemy enemy, int pos)
        {
            if (pos == 0)
            {
                ClearEnemyStats();
            }

            GameObject obj = Instantiate(statBarPrefab);

            obj.transform.SetParent(enemyGroup.transform, false);

            StatBar bar = obj.GetComponent <StatBar>();

            bar.SetSlider(enemy.Health, enemy.MaxHealth, enemy.Name, enemy.Color, enemy.Symbol);
        }
示例#13
0
 public void CurrentTileIsItem(Tile CurrentTile, Tile NextTile, List <Item> activeItems, Player player, string _direction)
 {
     for (int i = 0; i < activeItems.Count; i++)
     {
         if (activeItems[i].X == CurrentTile.X && activeItems[i].Y == CurrentTile.Y)
         {
             CurrentTile.Icon       = activeItems[i].Icon;
             CurrentTile.IsWalkable = true;
             NextTile.Icon          = PlayerIcon;
             NextTile.IsWalkable    = false;
             player.X = NextTile.X;
             player.Y = NextTile.Y;
             StatBar.Display(player);
             ActivityLog.AddToLog("You move " + _direction + ".");
         }
     }
 }
示例#14
0
    //StateBar RedStateBar;
    //StateBar BlueStateBar;
    //StateBar GreenStateBar;
    //StateBar GreyStateBar;

    // public Player (string name, int race, int[] Stats, int allignment)
    //     : base(name, race, Stats, allignment)
    // {
    //RedStateBar = new StateBar(Stats[0] + Stats[1] + Stats[2]);
    //BlueStateBar = new StateBar(Stats[0] + Stats[1] + Stats[2]);
    //GreenStateBar = new StateBar(Stats[0] + Stats[1] + Stats[2]);
    //GreyStateBar = new StateBar(15);
    // }

    //public string PlayerName;

    void Start()
    {
        Endurance    = GameControl.Endurance;
        CombatSkill  = GameControl.CombatSkill;
        WillPower    = GameControl.WillPower;
        Agility      = GameControl.Agility;
        Dexterity    = GameControl.Dexterity;
        Cunning      = GameControl.Cunning;
        Intelligence = GameControl.Intelligence;
        Wisdom       = GameControl.Wisdom;
        Talent       = GameControl.Talent;
        RedStatBar   = new StatBar(this.Endurance + this.CombatSkill + this.WillPower);
        BlueStatBar  = new StatBar(this.Agility + this.Dexterity + this.Cunning);
        GreenStatBar = new StatBar(this.Intelligence + this.Wisdom + this.Talent);
        GreyStatBar  = new StatBar(15);
        Total        = new StatBar(RedStatBar.MaxValue + BlueStatBar.MaxValue + GreenStatBar.MaxValue + GreyStatBar.MaxValue);
    }
示例#15
0
        public Character(Grid grid,
                         Tile currentTile,
                         Teams team,
                         CharacterType[] characterType,
                         GameManager gameManager,
                         GameNetworkManager gameNetworkManager)
        {
            this.grid = grid;
            currentTile.CurrentCharacter = this;
            this.team               = team;
            SpellReady              = false;
            this.characterType      = characterType;
            this.gameManager        = gameManager;
            this.gameNetworkManager = gameNetworkManager;
            ChooseSpell             = new ChooseSpell(this, ActiveSpells, gameNetworkManager);
            InactiveSpell           = new InactiveSpell(this, InactiveSpells, gameNetworkManager);

            Stats          = CharacterType.statsCopy();
            ActiveSpells   = new List <Spells[]>();
            InactiveSpells = new List <Spells[]>();
            LearnedSpells  = new List <Spells[]>();
            SpellLevel     = new Dictionary <Spells[], int>();
            brush          = (team == Teams.Blue) ? Brushes.BlueViolet : Brushes.Red;
            isBlue         = (team == Teams.Blue);
            statusEffects  = new List <StatusEffect>();

            IsDead = false;

            statsMultiplier = new Dictionary <StatusType, float>();
            statsAdder      = new Dictionary <StatusType, int>();
            foreach (StatusType statusType in Enum.GetValues(typeof(StatusType)))
            {
                statsAdder.Add(statusType, 0);
                statsMultiplier.Add(statusType, 1f);
            }

            hpBar = new StatBar(this,
                                team == Teams.Blue ? Brushes.GreenYellow : Brushes.OrangeRed, 0);
            charageBar = new StatBar(this, Brushes.Blue, 1);
        }
示例#16
0
 public void InitializeStatBar(StatBar sb, float value)
 {
     sb.SetValue(value);
 }
示例#17
0
    void Start()
    {
        // Subscriptions

        interaction                   = player.GetComponent <Interaction>();
        interaction.onVomit          += triggeredVomit;
        interaction.onMop2Vomit      += triggeredMop2Vomit;
        interaction.onCousin2Fight   += triggeredCousin2Fight;
        interaction.onSixPack2Fridge += triggeredSixPack2Fridge;
        interaction.onBeer2Dj        += triggeredBeer2Dj;

        /*public event Action onVomit;
         * public event Action onMop2Vomit;
         * public event Action onFight;
         * public event Action onCousin2Fight;
         * public event Action onSixPack2Fridge;
         * public event Action onBeer2Dj;*/
        interaction.onGetMop      += triggeredGetMop;
        interaction.onGetSixPack  += triggeredGetSixPack;
        interaction.onGetDrink    += triggeredGetDrink;
        interaction.onGetCousin   += triggeredGetCousin;
        interaction.onDropMop     += triggeredDropMop;
        interaction.onDropSixPack += triggeredDropSixPack;
        interaction.onDropDrink   += triggeredDropDrink;
        interaction.onDropCousin  += triggeredDropCousin;
        interaction.onFever       += triggeredFever;


        fightHandler             = handlerObject.GetComponent <FightHandler>();
        fightHandler.onNewFight += triggeredFight;

        // handlePeople = handlerObject.GetComponent<HandlePeople>();

        // Counters
        countersObject = transform.Find("Counters").gameObject;
        counter        = countersObject.GetComponent <Counters>();

        // Bar manager
        statBarManagerObject = transform.Find("StatBarManager").gameObject;
        statBarManager       = statBarManagerObject.GetComponent <StatBarManager>();

        // Bar objects and statbars
        safetyBarObject = transform.Find("StatBars/Safety").gameObject;
        statBarSafety   = safetyBarObject.GetComponent <StatBar>();

        boozeBarObject = transform.Find("StatBars/Booze").gameObject;
        statBarBooze   = boozeBarObject.GetComponent <StatBar>();

        cleannessBarObject = transform.Find("StatBars/Cleanness").gameObject;
        statBarCleanness   = cleannessBarObject.GetComponent <StatBar>();

        djFokusBarObject = transform.Find("StatBars/DJFokus").gameObject;
        statBarDjFokus   = djFokusBarObject.GetComponent <StatBar>();


        // Initializing bars
        statBarManager.InitializeStatBar(statBarSafety, statSafety);
        statBarManager.InitializeStatBar(statBarBooze, statBooze);
        statBarManager.InitializeStatBar(statBarCleanness, statCleanness);
        statBarManager.InitializeStatBar(statBarDjFokus, statDjFokus);

        // Automatically starting to decrease
        statBarManager.PeriodicallyChangeStatBar(statBarDjFokus, -0.02f);

        // Dynamic coroutine to reduce booze bar depending of the amount of npcs
        statBarManager.PeriodicallyChangeStatBarDependingOnPeople(statBarBooze, -0.003f);
        statBarManager.PeriodicallyChangeStatBarDependingOnFights(statBarSafety, -0.01f);
    }
	void Awake()
    {
        enemyHealth = gameObject.AddComponent<StatBar>();
        enemyHealth.Setup(100, 100, "Health");
        spriteRenderer = spriteObj.GetComponent<SpriteRenderer>();
    }
示例#19
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            DrawTransition();
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(_fillRect);

            if (_fillRect.objectReferenceValue != null)
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(_direction);
                if (EditorGUI.EndChangeCheck())
                {
                    StatBar.FillDirection direction = (StatBar.FillDirection)_direction.enumValueIndex;
                    foreach (var obj in serializedObject.targetObjects)
                    {
                        StatBar statBar = obj as StatBar;
                        statBar.SetDirection(direction, true);
                    }
                }

                EditorGUILayout.PropertyField(_minValue);
                EditorGUILayout.PropertyField(_maxValue);
                EditorGUILayout.PropertyField(_wholeNumbers);

                EditorGUILayout.Space();
                EditorGUILayout.Slider(_value, _minValue.floatValue, _maxValue.floatValue);
                EditorGUILayout.Space();

                DrawInfoArea();

                // Draw the event notification options
                EditorGUILayout.Space();
                EditorGUILayout.PropertyField(_onValueChanged);
            }
            else
            {
                EditorGUILayout.HelpBox("Specify a RectTransform for the stat bar to fill. It must have a parent RectTransform that it can slide within.", MessageType.Info);
            }

            serializedObject.ApplyModifiedProperties();

            void DrawTransition()
            {
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(_transition);
                StatBar.FillTransition transition = (StatBar.FillTransition)_transition.enumValueIndex;
                if (EditorGUI.EndChangeCheck())
                {
                    foreach (var obj in serializedObject.targetObjects)
                    {
                        StatBar statBar = obj as StatBar;
                        statBar.SetTransition(transition);
                    }
                }
                if (transition == StatBar.FillTransition.ColorTint)
                {
                    EditorGUI.indentLevel++;

                    DrawColorTintTransition(_normalColorTintTransition, "Normal");
                    DrawColorTintTransition(_lowColorTintTransition, "Low");
                    DrawColorTintTransition(_criticalColorTintTransition, "Critical");

                    EditorGUI.indentLevel--;
                }

                void DrawColorTintTransition(SerializedProperty property, string labelText)
                {
                    var percent = property.FindPropertyRelative("percent");
                    var color   = property.FindPropertyRelative("color");

                    EditorGUILayout.LabelField(labelText);
                    EditorGUI.indentLevel++;
                    EditorGUILayout.IntSlider(percent, 0, 100);
                    EditorGUILayout.PropertyField(color);
                    EditorGUI.indentLevel--;
                }
            }

            void DrawInfoArea()
            {
                EditorGUILayout.PropertyField(_valueLabel);
                if (_valueLabel.objectReferenceValue != null)
                {
                    var textHolder = _valueLabel.objectReferenceValue as RectTransform;
                    if (textHolder.GetComponent <Text>() ||
                        textHolder.GetComponent <TMPro.TMP_Text>())
                    {
                        EditorGUILayout.IntSlider(_minDigits, 1, 10);
                    }
                    else
                    {
                        _valueLabel.objectReferenceValue = null;
                    }
                }
                else
                {
                    EditorGUILayout.HelpBox("Specify a RectTransform whith a Text or TMP_Text component for the stat bar to set the value.", MessageType.Info);
                }
            }
        }
        public override void LoadContent()
        {
            ContentManager content = new ContentManager(ScreenManager.Game.Services, "Content");
            bill = content.Load<Texture2D>("bill");
            laptop = content.Load<Texture2D>("laptop");
            // Load item icons here.
            temp_item = content.Load<Texture2D>("inv_items/energy_drink_icon");

            //

            overlay_background = new RectangleOverlay(new Rectangle(0, 0, GlobalConstants.ScreenWidth, GlobalConstants.ScreenHeight), this);
            top = new RectangleOverlay(new Rectangle(6, 6, GlobalConstants.ScreenWidth - 12, GlobalConstants.ScreenHeight - 360), this);
            bot = new RectangleOverlay(new Rectangle(6,  GlobalConstants.ScreenHeight - 351, GlobalConstants.ScreenWidth - 12, 345), this);
            overlay_background.LoadContent();
            top.LoadContent();
            bot.LoadContent();

            //

            energyBar_Bill = new StatBar(new Rectangle(120, 12, 140, 20), this, true);
            energyBar_Bill.LoadContent();
            energyBarPos_Bill = new Vector2(120, 33);

            expBar_Bill = new StatBar(new Rectangle(120, 55, 140, 20), this, false);
            expBar_Bill.LoadContent();
            expBarPos_Bill = new Vector2(120, 76);

            facePos_Bill = new Vector2(12, 12);
            levelPos_Bill = new Vector2(facePos_Bill.X, facePos_Bill.Y + 95);
            strdefPos_Bill = new Vector2();

            //

            energyBar_Laptop = new StatBar(new Rectangle(488, 12, 140, 20), this, true);
            energyBar_Laptop.LoadContent();
            energyBarPos_Laptop = new Vector2(488, 33);

            expBar_Laptop = new StatBar(new Rectangle(488, 55, 140, 20), this, false);
            expBar_Laptop.LoadContent();
            expBarPos_Laptop = new Vector2(488, 76);

            facePos_Laptop = new Vector2(380, 12);
            levelPos_Laptop = new Vector2(facePos_Bill.X, facePos_Bill.Y + 95);
            strdefPos_Laptop = new Vector2();

            //

            selectedItem = 0;
            itemPosition = new Vector2(12, GlobalConstants.ScreenHeight - 339);
            itemDescriptionPosition = new Vector2(itemPosition.X + temp_item.Width + 10, itemPosition.Y);

            //
        }
示例#21
0
 public void SetStatBar(StatBar _statBar)
 {
     bar = _statBar;
 }
示例#22
0
    //Links the player to the HUD
    private void LinkHUD()
    {
        StatBar Healthbar = transform.GetChild(0).GetChild(1).GetChild(0).GetComponent <StatBar>();

        PlayerHealth.OnValueChange += Healthbar.UpdateUI;
    }
示例#23
0
 private void Awake()
 {
     statBar = this.GetComponentInParent <StatBar>();
     text    = GetComponent <Text>();
 }
 // Start is called before the first frame update
 void Start()
 {
     health = new StatBar(healthContainer.transform);
     xp     = new StatBar(xpContainer.transform);
 }