コード例 #1
0
 protected override void ReceiveValue(Unit target)
 {
     if (colors.TryGetValue(target.team, out var color))
     {
         GetComponent <Graphic>().color = color;
     }
 }
コード例 #2
0
    protected virtual void Handle()
    {
        var current = selector.GetValue(data);

        if (parameters.TryGetValue(current, out var parameter))
        {
            onUpdate.Invoke(parameter);
        }
        else
        {
            if (selectClosest)
            {
                var closest     = defaultParam;
                var closestDist = float.PositiveInfinity;
                foreach (var kv in parameters)
                {
                    var dist = Mathf.Abs(kv.Key - current);
                    if (dist < closestDist)
                    {
                        closest     = kv.Value;
                        closestDist = dist;
                    }
                }
                onUpdate.Invoke(closest);
                return;
            }
            onUpdate.Invoke(defaultParam);
        }
    }
コード例 #3
0
 protected void RemoveItem(UnitModifier modifier)
 {
     if (dynamics.TryGetValue(modifier, out var val))
     {
         Destroy(val);
         dynamics.Remove(modifier);
     }
 }
コード例 #4
0
 protected override void ReceiveValue(Ability data)
 {
     if (colors.TryGetValue(data.abilityType.current, out var color))
     {
         onUpdate.Invoke(color);
     }
     else
     {
         onUpdate.Invoke(Color.white);
     }
 }
コード例 #5
0
    protected virtual void Handle()
    {
        var current = selector.GetValue(data);

        if (parameters.TryGetValue(current, out var parameter))
        {
            onUpdate.Invoke(parameter);
        }
        else
        {
            onUpdate.Invoke(defaultParam);
        }
    }
コード例 #6
0
ファイル: EnumReader.cs プロジェクト: Satsaa/KalsiumHeroes
    protected virtual void Handle()
    {
        var current = selector.GetValue(data);

        if (strIds.TryGetValue(current, out var strId))
        {
            onUpdate.Invoke(Lang.GetStr(strId));
        }
        else
        {
            var name = current?.GetType().GetEnumName(current) ?? "None";
            onUpdate.Invoke(name);
        }
    }
コード例 #7
0
    private void OnResearchClickHandler(object sender, ResearchType rType)
    {
        if (!ResearchCostDictionary.TryGetValue(rType, out var value))
        {
            return;
        }

        if (value <= MapData.BrainAmount)
        {
            MapData.BrainAmount -= value;

            var rButt = (ResearchButton)sender;
            rButt.RState = ResearchState.Researched;

            foreach (var dependentButt in rButt.dependentButts)
            {
                dependentButt.RState = ResearchState.Unlocked;
                dependentButt.RefreshResearchState();
            }

            //todo: apply research effects

            switch (rType)
            {
            case ResearchType.ATTACK:
                MapData.CurrentMaxAttack += 2f;
                break;

            case ResearchType.HEALTH:
                MapData.CurrentMaxHealth += 10f;
                break;

            case ResearchType.SPEED:
                MapData.CurrentMaxSpeed += 5f;
                break;

            case ResearchType.COST:
                MapData.CurrentMaxSpeed -= 0.05f;
                break;

            case ResearchType.ATTACK2:
                MapData.CurrentMaxAttack += 3f;
                break;

            case ResearchType.HEALTH2:
                MapData.CurrentMaxHealth += 10f;
                break;

            case ResearchType.SPEED2:
                MapData.CurrentMaxSpeed += 5f;
                break;

            case ResearchType.COST2:
                MapData.CurrentMaxSpeed -= 0.1f;
                break;

            case ResearchType.ATTACK3:
                MapData.CurrentMaxAttack += 5f;
                break;

            case ResearchType.HEALTH3:
                MapData.CurrentMaxAttack += 5f;
                break;

            case ResearchType.SPEED3:
                MapData.CurrentMaxSpeed += 5f;
                break;

            case ResearchType.COST3:
                MapData.CurrentMaxSpeed -= 0.1f;
                break;

            case ResearchType.THEALTH:
                MapData.CurrentTreeHealth += 250f;
                break;

            case ResearchType.THEALTH2:
                MapData.CurrentTreeHealth += 250f;
                break;

            case ResearchType.THEALTH3:
                MapData.CurrentTreeHealth += 250f;
                break;

            case ResearchType.TATTACK:
                MapData.CurrentTreeAttack += 10f;
                break;

            case ResearchType.TATTACK2:
                MapData.CurrentTreeAttack += 10f;
                break;

            case ResearchType.TATTACK3:
                MapData.CurrentTreeAttack += 10f;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(rType), rType, null);
            }
        }
    }