Example #1
0
    public MPlayer(int index, bool isHuman, string name, MColor color)
    {
        this.index = index;
        this.isHuman = isHuman;
        this.name = name;
        this.color = color;

        framesTillBeast = maxFramesTillBeast;

        stats = new MPlayerStat[4];

        stats[0] = statSpeed = new MPlayerStat(0,"speed",0,30);
        stats[1] = statAttack = new MPlayerStat(1,"attack",0,30);
        stats[2] = statDefence = new MPlayerStat(2,"defence",0,30);
        stats[3] = statHealth = new MPlayerStat(3,"health",0,30);

        currentStatTotal = 0;
        statTotal = 0;

        foreach(MPlayerStat stat in stats)
        {
            stat.player = this;
            statTotal += stat.max;
            stat.SignalChange += HandleStatChange;
        }

        isDirty = true;
    }
Example #2
0
    private void HandleStatChange(MPlayerStat stat)
    {
        _title.text = stat.name.ToUpper() + ": " + (stat.amount) + "/" + stat.max;

        if(stat.amount == stat.max)
        {
            _button.label.text = "MAXED!";
        }
        else
        {
            _button.label.text = (stat.amount+1)+"&";
        }

        Update();
    }
Example #3
0
    public MStatView(MPlayerStat stat)
    {
        this.stat = stat;
        stat.SignalChange += HandleStatChange;

        AddChild(_title = new FLabel("Cubano", ""));
        _title.anchorY = 0.0f;
        _title.y = 27.0f;
        _title.scale = 0.4f;

        AddChild(_button = new FButton("SquareButtonBG_normal.png", "SquareButtonBG_over.png","Click"));
        _button.AddLabel("Cubano", "", Color.white);
        _button.label.text = "";
        _button.label.scale = 0.75f;

        _button.isEnabled = false;

        _button.SignalRelease += HandleButtonClick;

        HandleStatChange (stat);
    }
Example #4
0
    private void HandleStatChange(MPlayerStat stat)
    {
        currentStatTotal = 0;
        foreach(MPlayerStat eachStat in stats)
        {
            currentStatTotal += eachStat.amount;
        }

        if(currentStatTotal % leapThreshold == 0 && statTotal != 0)
        {
            int newLeapLevel = (int) Mathf.Floor ((float)currentStatTotal/(float)leapThreshold);

            if(leapLevel != newLeapLevel)
            {
                leapLevel = newLeapLevel;

                FSoundManager.PlaySound("EvolutionaryLeap",1.0f);

                if(currentStatTotal == statTotal)
                {
                    if(isHuman) MGame.instance.ShowNote("MAX EVOLVED!", 3.0f);
                }
                else
                {
                    if(isHuman) MGame.instance.ShowNote("EVOLUTIONARY LEAP!\n +25% TO ALL MUTATIONS", 5.0f);

                    foreach(MPlayerStat eachStat in stats)
                    {
                        eachStat.Leap();
                    }
                }
            }
        }

        isDirty = true;
        areStatsDirty = true;
    }