Beispiel #1
0
 public void UpdateGlobalStat(StatPanel statPanel, int value)
 {
     if (statPanel != null)
     {
         statPanel.StatManager.StatToValue(statPanel.StatManager.GetStat("Amount")).Value += value;
     }
 }
Beispiel #2
0
    private void createStatPanel()
    {
        if (null == PrefStatPanel)
        {
            Log.Error("not found prefab stat panel");
            return;
        }

        if (null == StatListPanel)
        {
            Log.Error("not found stat list panel");
            return;
        }

        Array statTypeArray = Enum.GetValues(typeof(EStat));

        const int NUM_STAT = (int)EStat.MAX;

        for (int i = 0; i < NUM_STAT; ++i)
        {
            GameObject o = Instantiate(PrefStatPanel);
            o.transform.SetParent(StatListPanel.transform, false);

            EStat stat = (EStat)statTypeArray.GetValue(i);

            StatPanel p = o.GetComponent <StatPanel>();
            p.Set(stat);
        }
    }
Beispiel #3
0
        private static void Render()
        {
            Terminal.Clear();
            Terminal.Layer(1);

            if (Player != null)
            {
                Map.Draw(_mapLayer);
                MessageHandler.Draw(_messageLayer);
                StatPanel.Draw(_statLayer);

                if (ShowInfo)
                {
                    InfoPanel.Draw(_leftLayer);
                }
                else
                {
                    LookPanel.Draw(_leftLayer);
                }

                if (ShowEquip)
                {
                    Player.Equipment.Draw(_rightLayer);
                }
                else
                {
                    Player.Inventory.Draw(_rightLayer);
                }
            }

            StateHandler.Draw();
            Animations.Draw();

            Terminal.Refresh();
        }
Beispiel #4
0
    private void create()
    {
        if (null != PrefBackButton)
        {
            GameObject o = Instantiate(PrefBackButton);
            o.transform.SetParent(transform, false);

            Button BackButton = o.GetComponent <Button>();
            BackButton.onClick.AddListener(onClickBackButton);
        }
        else
        {
            Log.Error("not found prefab back button");
        }

        if (null != PrefStatPanel)
        {
            GameObject o = Instantiate(PrefStatPanel);
            o.transform.SetParent(StatsPanel.transform, false);

            StatPanel sp = o.GetComponent <StatPanel>();
            sp.Set(EStat.STRESS);
        }
        else
        {
            Log.Error("not found prefab stat panel");
        }
    }
Beispiel #5
0
    void OnEnable()
    {
        StatPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (float)(30 * 2) + 15);
//		UnityEventManager.StartListeningInt("UpdateFood", SetFood);
//		UnityEventManager.StartListeningInt("UpdateHealth", SetHealth);
//		UnityEventManager.StartListeningInt("MoMDeath", Notify);
        StartCoroutine(UpdateInfo());
    }
    StatusIndicatorEntry Dequeue(StatPanel panel)
    {
        Poolable             p     = GameObjectPoolController.Dequeue(EntryPoolKey);
        StatusIndicatorEntry entry = p.GetComponent <StatusIndicatorEntry>();

        entry.transform.SetParent(panel.statusParent.transform, false);
        entry.transform.localScale = Vector3.one;
        entry.gameObject.SetActive(true);
        return(entry);
    }
 void MovePanel(StatPanel obj, string pos, ref Tweener t)
 {
     Panel.Position target = obj.panel [pos];
     if (obj.panel.CurrentPosition != target) {
         if(t != null && t != null)
             t.Stop();
         t = obj.panel.SetPosition(pos, true);
         t.duration = 0.5f;
         t.equation = EasingEquations.EaseOutQuad;
     }
 }
Beispiel #8
0
    public void Startup()
    {
        gameResources = new Dictionary <int, GameResource>();

        using (IDataReader dr = Managers.Database.GetSQLiteQuery("SELECT * FROM resources;"))
        {
            while (dr.Read())
            {
                GameResource res = new GameResource(dr);
                gameResources[res.ID] = res;
            }

            userResources = new Dictionary <int, int>();

            dr.Close();
        }
        using (IDataReader dr = Managers.Database.GetSQLiteQuery(String.Format("SELECT resource_id, count FROM InitialStorage;"
                                                                               , Managers.Session.GetSession())))
        {
            while (dr.Read())
            {
                userResources[Convert.ToInt32(dr["resource_id"])] = Convert.ToInt32(dr["count"]);
            }

            dr.Close();
        }

        using (IDataReader dr = Managers.Database.GetSQLiteQuery(String.Format("SELECT resource_id, count FROM Storage WHERE session_id = {0};"
                                                                               , Managers.Session.GetSession())))
        {
            while (dr.Read())
            {
                userResources[Convert.ToInt32(dr["resource_id"])] = Convert.ToInt32(dr["count"]);
            }

            dr.Close();
        }

        using (IDataReader dr = Managers.Database.GetSQLiteQuery("SELECT * FROM MaxStorage;"))
        {
            resourceLimits = new Dictionary <int, int>();

            while (dr.Read())
            {
                resourceLimits[Convert.ToInt32(dr["resource_id"])] = Convert.ToInt32(dr["count"]);
            }
            dr.Close();
        }


        stat_panel = panel;
        stat_panel.SetPanel();
        status = ManagerStatus.Started;
    }
Beispiel #9
0
    public void LoadUi(CharacterInventory pinventory, CharacterStats pstats)
    {
        statPanel      = transform.Find("CharacterStatPanel").gameObject;
        inventoryPanel = transform.Find("CharacterInventoryUi").gameObject;

        stats     = statPanel.GetComponent <StatPanel>();
        itemPanel = inventoryPanel.GetComponent <ItemPanel>();

        itemPanel.Initalize(pinventory);
        stats.Initalize();
    }
Beispiel #10
0
    public bool SetStatPanelActiveState(bool active, string type)
    {
        StatPanel statPanel = StatPanels.FirstOrDefault(x => x.Type == type);

        if (statPanel != null)
        {
            statPanel.Tab.SetActive(active);
            statPanel.SetActive(active);
            return(true);
        }
        return(false);
    }
Beispiel #11
0
    public void GenerateStatsForPanel(StatPanel panel, ManageableObjet obj)
    {
        Type t = obj.GetType();

        if (panel != null)
        {
            t.GetMethod("GenerateStats").Invoke(obj, new object[] { panel });
            //panel.StatManager.GenerateStat<ValueStat>(mainStat: true, name: "Amount").Populate(0, 0, 100, "Nombre de " + obj.Type.Split(' ')[0] + "s", true, "Amount");
            UpdateGlobalStat(panel, 1);
            panel.StatManager.GetStat("Amount").SetActive(false);
        }
    }
Beispiel #12
0
 void MovePanel(StatPanel obj, string pos, ref Tweener t)
 {
     UIPanel.Position target = obj.panel[pos];
     if (obj.panel.CurrentPosition != target)
     {
         if (t != null && t.easingControl != null)
         {
             t.easingControl.Stop();
         }
         t = obj.panel.SetPosition(pos, true);
         t.easingControl.duration = 0.5f;
         t.easingControl.equation = EasingEquations.EaseOutQuad;
     }
 }
Beispiel #13
0
    private void FixedUpdate()
    {
        // Setup Events:
        // Right Click
        if (CharacterPanel == null)
        {
            return;
        }

        inventory      = CharacterPanel.transform.Find("Inventory").gameObject.GetComponent <Inventory>();
        itemTooltip    = CharacterPanel.transform.Find("ItemTooltip").gameObject.GetComponent <ItemTooltip>();
        equipmentPanel = CharacterPanel.transform.Find("EquipmentPanel").gameObject.GetComponent <EquipmentPanel>();
        statPanel      = CharacterPanel.transform.Find("StatPanel").gameObject.GetComponent <StatPanel>();
        draggableItem  = CharacterPanel.transform.Find("Image").gameObject.GetComponent <Image>();
        chest          = MainHud.transform.Find("ChestPanel").gameObject.GetComponent <Chest>();

        inventory.OnRightClickEvent      += Equip;
        chest.OnRightClickEvent          += GoToInventory;
        equipmentPanel.OnRightClickEvent += UnEquip;
        //Pointer Enter
        inventory.OnPointerEnterEvent      += ShowTooltip;
        equipmentPanel.OnPointerEnterEvent += ShowTooltip;
        //Pointer Exit
        inventory.OnPointerExitEvent      += HideTooltip;
        equipmentPanel.OnPointerExitEvent += HideTooltip;
        //Begin Drag
        inventory.OnBeginDragEvent      += BeginDrag;
        equipmentPanel.OnBeginDragEvent += BeginDrag;
        //End Drag
        inventory.OnEndDragEvent      += EndDrag;
        equipmentPanel.OnEndDragEvent += EndDrag;
        //Drag
        inventory.OnDragEvent      += Drag;
        equipmentPanel.OnDragEvent += Drag;
        //Drop
        inventory.OnDropEvent      += Drop;
        equipmentPanel.OnDropEvent += Drop;


        Strength.BaseValue     = CharConfig.Instance.charData.STR;
        Agility.BaseValue      = CharConfig.Instance.charData.AGI;
        Intelligence.BaseValue = CharConfig.Instance.charData.INT;
        Vitality.BaseValue     = CharConfig.Instance.charData.VIT;
        Dexterity.BaseValue    = CharConfig.Instance.charData.DEX;
        Luck.BaseValue         = CharConfig.Instance.charData.LUK;

        statPanel.SetStats(Strength, Agility, Intelligence, Vitality, Dexterity, Luck);
        statPanel.UpdateStatValues();
    }
Beispiel #14
0
    private void SetStats()
    {
        stats.text = $"total shots: {match.shots}, airdrops picked up: {match.ADTotal}";
        for (int i = 0; i < clients.Count; i++)
        {
            StatPanel panel = Instantiate(StatPanel, StatPanelContainer).GetComponent <StatPanel>();
            statPanels.Add(panel.gameObject);
            panel.SetUsername(clients[i].username);
            panel.SetScore(clients[i].score);
            panel.SetPlacementIcon(i + 1);

            //stats
            panel.SetCommonStats(playerStats[i].kills, playerStats[i].shots, playerStats[i].closeCalls, playerStats[i].ADTotal);
            panel.SetADStats(playerStats[i]);
        }
    }
Beispiel #15
0
    void Awake()
    {
        if (null != PrefCalendarPanel)
        {
            GameObject o = Instantiate(PrefCalendarPanel);
            o.transform.SetParent(transform, false);
            o.transform.SetAsFirstSibling();
        }
        else
        {
            Log.Error("not found prefab calendar panel");
        }

        _statPanelList = new List <StatPanel>();
        for (int i = 0; i < DEFAULT_NUM_STAT_PANEL; ++i)
        {
            GameObject o = Instantiate(PrefStatPanel);
            o.transform.SetParent(StatsPanel.transform, false);

            StatPanel p = o.GetComponent <StatPanel>();
            _statPanelList.Add(p);
        }

        _backgroundImage = GetComponent <Image>();
        _animController  = AnimImage.GetComponent <RunScheduleAnimController>();

        _schedule = Manager.Instance.Object.NurtureMode.Schedule;
        _schedule.ActionCancelEvent.Attach(onActionCancel);
        _schedule.ActionStartEvent.Attach(onActionStart);
        _schedule.ActionFirstEvent.Attach(onActionFirst);
        _schedule.ActionFirstEvent.Attach(onActionFirstNPC);
        _schedule.ActionDoEvent.Attach(onActionDo);
        _schedule.ActionDoEvent.Attach(onActionDoResult);
        _schedule.ActionBeforeEndEvent.Attach(onActionBeforeEnd);
        _schedule.ActionBeforeEndEvent.Attach(onActionBeforeEndExam);
        _schedule.ActionEndEvent.Attach(onActionEnd);
        _schedule.ActionEndEvent.Attach(onActionEndAchievement);

        Nurture.Mode nurtureMode = Manager.Instance.Object.NurtureMode;
        nurtureMode.Schedule.StartEvent.Attach(onScheduleStart);
        nurtureMode.Schedule.EndEvent.Attach(onScheduleEnd);
    }
Beispiel #16
0
        protected override void LoadContent()
        {
            this.IsMouseVisible = true;

            this.graphics.PreferredBackBufferWidth  = GlobalVariables.WindowWidthDefault;  // set this value to the desired width of your window
            this.graphics.PreferredBackBufferHeight = GlobalVariables.WindowHeightDefault; // set this value to the desired height of your window
            this.graphics.ApplyChanges();

            this.statPanel   = new StatPanel();
            this.startScreen = new StartScreen();
            this.deathScreen = new DeathScreen();

            this.stage = GameStages.Start_Stage;

            // Create a new SpriteBatch, which can be used to draw textures.
            this.spriteBatch = new SpriteBatch(this.GraphicsDevice);

            GfxHandler.Load(this.Content);

            this.startScreen.Load(this.Content);
            this.deathScreen.Load(this.Content);
            this.statPanel.Load(this.Content);
        }
Beispiel #17
0
        protected override void LoadContent()
        {
            this.IsMouseVisible = true;

            this.graphics.PreferredBackBufferWidth = GlobalVariables.WindowWidthDefault; // set this value to the desired width of your window
            this.graphics.PreferredBackBufferHeight = GlobalVariables.WindowHeightDefault;   // set this value to the desired height of your window
            this.graphics.ApplyChanges();

            this.statPanel = new StatPanel();
            this.startScreen = new StartScreen();
            this.deathScreen = new DeathScreen();

            this.stage = GameStages.Start_Stage;

            // Create a new SpriteBatch, which can be used to draw textures.
            this.spriteBatch = new SpriteBatch(this.GraphicsDevice);

            GfxHandler.Load(this.Content);

            this.startScreen.Load(this.Content);
            this.deathScreen.Load(this.Content);
            this.statPanel.Load(this.Content);
        }
    private void Awake()
    {
        _inventory      = GameObject.Find("Inventory").GetComponent <Inventory>();
        _equipmentPanel = GameObject.Find("EquipmentPanel").GetComponent <EquipmentPanel>();

        _shopInventory = GameObject.Find("ShopPanel").GetComponent <ShopInventory>();
        _playerCoins   = GameObject.Find("Coins").GetComponent <PlayerCoins>();

        _itemTooltip         = GameObject.Find("ItemTooltip").GetComponent <ItemTooltip>();
        _statTooltip         = GameObject.Find("StatTooltip").GetComponent <StatTooltip>();
        _draggedItem         = GameObject.Find("DraggedItem").GetComponent <Image>();
        _draggedItem.enabled = false;

        _statsPanel = GameObject.Find("Stats").GetComponent <StatPanel>();
        _statsPanel.SetStats(_health, _mana, _armor, _strength, _intelligence);
        GameController.maxHealth    = _health.Value;
        GameController.maxMana      = _mana.Value;
        GameController.armor        = _armor.Value;
        GameController.strength     = _strength.Value;
        GameController.intelligence = _intelligence.Value;
        _statsPanel.UpdateStatValues();

        //Setup Events:
        GameController.OnUseConsumableEvent += UseConsumable;
        //Right Click
        _inventory.OnRightClickEvent      += Equip;
        _inventory.OnRightClickEvent      += Sell;
        _inventory.OnRightClickEvent      += UseConsumable;
        _inventory.OnRightClickEvent      += HideTooltip;
        _equipmentPanel.OnRightClickEvent += Unequip;
        _shopInventory.OnRightClickEvent  += Buy;
        _shopInventory.OnRightClickEvent  += HideTooltip;
        //Pointer Enter
        _inventory.OnPointerEnterEvent      += ShowTooltip;
        _equipmentPanel.OnPointerEnterEvent += ShowTooltip;
        _shopInventory.OnPointerEnterEvent  += ShowTooltip;
        //Pointer Exit
        _inventory.OnPointerExitEvent      += HideTooltip;
        _equipmentPanel.OnPointerExitEvent += HideTooltip;
        _shopInventory.OnPointerExitEvent  += HideTooltip;
        //Begin Drag
        _inventory.OnBeginDragEvent      += BeginDrag;
        _inventory.OnBeginDragEvent      += HideTooltip;
        _equipmentPanel.OnBeginDragEvent += BeginDrag;
        _shopInventory.OnBeginDragEvent  += BeginDrag;
        //End Drag
        _inventory.OnEndDragEvent      += EndDrag;
        _equipmentPanel.OnEndDragEvent += EndDrag;
        _shopInventory.OnEndDragEvent  += EndDrag;
        //Drag
        _inventory.OnDragEvent      += Drag;
        _equipmentPanel.OnDragEvent += Drag;
        _shopInventory.OnDragEvent  += Drag;
        //Drop
        _inventory.OnDropEvent      += Drop;
        _inventory.OnDropEvent      += ShowTooltip;
        _equipmentPanel.OnDropEvent += Drop;
        _equipmentPanel.OnDropEvent += ShowTooltip;
        _shopInventory.OnDropEvent  += Drop;
        _shopInventory.OnDropEvent  += ShowTooltip;
    }
Beispiel #19
0
	public void SetTeams(int t)
	{
		StatPanel.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, (float)(30*t)+15);
	}
Beispiel #20
0
    private void initStat(Action action)
    {
        if (null == StatsPanel)
        {
            Log.Error("not found stats panel");
            return;
        }

        List <EStat> statList = new List <EStat>();

        if (action.stress != 0)
        {
            statList.Add(EStat.STRESS);
        }

        if (action.stamina != 0)
        {
            statList.Add(EStat.STAMINA);
        }
        if (action.intellect != 0)
        {
            statList.Add(EStat.INTELLECT);
        }
        if (action.grace != 0)
        {
            statList.Add(EStat.GRACE);
        }
        if (action.charm != 0)
        {
            statList.Add(EStat.CHARM);
        }

        if (action.attack != 0)
        {
            statList.Add(EStat.ATTACK);
        }
        if (action.defense != 0)
        {
            statList.Add(EStat.DEFENSE);
        }

        if (action.leadership != 0)
        {
            statList.Add(EStat.LEADERSHIP);
        }
        if (action.tactic != 0)
        {
            statList.Add(EStat.TACTIC);
        }

        if (action.morality != 0)
        {
            statList.Add(EStat.MORALITY);
        }
        if (action.goodness != 0)
        {
            statList.Add(EStat.GOODNESS);
        }

        if (action.sensibility != 0)
        {
            statList.Add(EStat.SENSIBILITY);
        }
        if (action.arts != 0)
        {
            statList.Add(EStat.ARTS);
        }

        int numMoreNeedStatPanel = statList.Count - _statPanelList.Count;

        if (numMoreNeedStatPanel > 0)
        {
            for (int i = 0; i < numMoreNeedStatPanel; ++i)
            {
                GameObject o = Instantiate(PrefStatPanel);
                o.transform.SetParent(StatsPanel.transform, false);

                StatPanel p = o.GetComponent <StatPanel>();
                _statPanelList.Add(p);
            }
        }

        int statListCount      = statList.Count;
        int statPanelListCount = _statPanelList.Count;

        for (int i = 0; i < statListCount; ++i)
        {
            _statPanelList[i].Set(statList[i]);
            _statPanelList[i].Show();
        }
        for (int i = statList.Count; i < statPanelListCount; i++)
        {
            _statPanelList[i].Hide();   // hide unused panel
        }
    }
        public void StatPanelUpdate()
        {
            StatPanel.Controls.Clear();
            PerksPanel.Controls.Clear();
            PerksPanel.Size     = new Size(0, perksPanelPadding * 2 + perksPanelSide);
            PerksPanel.Location = new System.Drawing.Point(ClientSize.Width - (256 + perksPanelSide),
                                                           ClientSize.Height - (perksPanelSide + 24));
            var button = new Button()
            {
                Width     = 256,
                Height    = 64,
                Text      = "END TURN",
                Font      = new Font(FontFamily.GenericSerif, 32),
                ForeColor = Color.White,
                BackColor = Colors.PlayerDarkColors
                            [Game.Players.IndexOf(Game.CurrentPlayer) % Colors.count]
            };

            if (Game.Winner == null)
            {
                button.Click += (sender, args) =>
                {
                    EveryUpdate();
                    Controls.Remove(ShopPanel);
                    Game.EndTurn();
                    PlayerPanelUpdate();
                    StatPanelUpdate();
                    Controls.Remove(HeroPanel);
                    HeroPanel = new CurrentHeroPanel(Game.CurrentHero, this)
                    {
                        Size     = new Size(128, 128),
                        Anchor   = AnchorStyles.Bottom | AnchorStyles.Left,
                        Location = new System.Drawing.Point(32, ClientSize.Height - 160)
                    };
                    Controls.Add(HeroPanel);
                    HeroPanel.BringToFront();
                    ShopPanel = new ShopPanel(Game.CurrentHero, this,
                                              new Rectangle(ClientSize.Width / 2 - 480, ClientSize.Height / 2 - 300, 960, 600));

                    SkillPanel = new HeroSkillPanel(Game, Game.CurrentHero, this, ControlPanel.Width);
                    CenterOnPoint(Game.Maze.UnitPositions[Game.CurrentHero]);
                    ControlPanelUpdate();
                    MapUpdate();
                }
            }
            ;
            else
            {
                button.Text   = "END GAME";
                button.Click += (sender, args) => this.Close();
            }
            StatPanel.Controls.Add(button);

            if (Game.ChosenHero != null)
            {
                var h = new HeroInfo(Game.ChosenHero)
                {
                    Width = StatPanel.Width - 6,
                };
                StatPanel.Controls.Add(h);

                StatPanel.Controls.Add(new Label
                {
                    BackColor = Color.Black,
                    ForeColor = Colors.PlayerLightColors
                                [Game.Players.IndexOf(Game.ChosenHero.P) % Colors.count],
                    Text      = Game.ChosenHero.Name,
                    Font      = new Font(FontFamily.GenericSansSerif, 16),
                    Width     = StatPanel.Width - 6,
                    Height    = 32,
                    TextAlign = ContentAlignment.MiddleCenter
                });

                foreach (var perk in Game.ChosenHero.Perks.Where(p => p.Name != "Perk"))
                {
                    PerksPanel.Controls.Add(new Label
                    {
                        AutoSize  = true,
                        BackColor = Color.Black,
                        Text      = double.IsNaN(perk.Number(Game.ChosenHero)) ?
                                    perk.Name : perk.Name + "\n" + perk.Number(Game.ChosenHero),
                        MinimumSize = new Size(perksPanelSide, perksPanelSide),
                        MaximumSize = new Size(1000, perksPanelSide),
                        Font        = new Font(FontFamily.GenericSansSerif, 16),
                        ForeColor   = Color.Aqua,
                        TextAlign   = ContentAlignment.MiddleCenter,
                        Margin      = new Padding(perksPanelPadding)
                    });
                }
            }
            StatPanel.Refresh();
            PerksPanel.Refresh();
        }