当前位置: 首页>>代码示例>>C#>>正文


C# Unit.getClay方法代码示例

本文整理汇总了C#中Unit.getClay方法的典型用法代码示例。如果您正苦于以下问题:C# Unit.getClay方法的具体用法?C# Unit.getClay怎么用?C# Unit.getClay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Unit的用法示例。


在下文中一共展示了Unit.getClay方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttackRound

	// Sets damage done by one round of attacking.
    // Must be re-set after doing this; assumes within countering range.
	public AttackRound(Unit attackerIn, int attackerWaterCost, Unit defenderIn) {
        attacker = attackerIn;
		defender = defenderIn;

        utility = expectedDamage = expectedCounterDamage = 0;
        dieDef = dieAtk = false;

        // Store current stats.
        waterAtk = attacker.getCurrentWater();
        clayDef = defender.getClay();

        attacker.setCurrentWater(waterAtk - attackerWaterCost);

		expectedDamage = calculateExpectedDamage(attacker, defender);

        // Assume defender looses appropriate amount of clay before counter.
        if ((clayDef - expectedDamage) > 0)
        {
            defender.setClay(clayDef - expectedDamage);
            expectedCounterDamage = calculateExpectedDamage(defender, attacker);
        }
        else
        {
            defender.setClay(0);
            dieDef = true;
        }

        if ((attacker.getClay() - expectedDamage) < 0)
        {
            dieAtk = true;
        }

		// Calculates a utility value using expected damage values
		utility = calculateUtility();
    }
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:37,代码来源:AttackRound.cs

示例2: Attack

	// Calculates the damage, hit chance and critical chance of an attack from one unit to another
    // Goal to max attack: maximize water.
	public Attack(Unit attacker, Unit defender) {
        atk = attacker;
        def = defender;
		damage = Mathf.Max(attacker.getClay() - defender.getHardness(), 0);
        // TODO: water: fix this to be more balanced.
        float waterVal = Mathf.Max(attacker.getMaxWater() / 2, attacker.getCurrentWater());
		hitChance = Mathf.Min((waterVal - defender.getBendiness()) / defender.getBendiness(), 1.0f);
		critChance = Mathf.Min((attacker.getBendiness() - defender.getBendiness()) / defender.getBendiness(), 1.0f);
	}
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:11,代码来源:Attack.cs

示例3: RunAI

    /// <summary>
    /// Run AI for a unit, returning a UnitAction.
    /// </summary>
    /// <param name="subject">The subject to run AI on.</param>
    /// <param name="subjectsEnemies">The current list of the subject's enemies.</param>
    /// <returns>The best UnitAction to take.</returns>
    public UnitAction RunAI(Unit subject, List<Unit> subjectsEnemies)
    {
        subjectRef = subject;
        subjectsEnemiesRef = subjectsEnemies;

        pathManager.calcUnitPaths(subjectRef, subjectsEnemies);

        int sanityCheck = subjectRef.getClay();
        
        KeyValuePair<Result, UnitAction> MinMaxResult = MinMax();
        if (subjectRef.getClay() != sanityCheck)
            UnityEngine.Debug.Log("ERROR IN MINMAX AGAIN!");
        switch (MinMaxResult.Key)
        {
            case Result.Success:
                return MinMaxResult.Value;

            // Nothing in range.
            case Result.NothingFound:
                KeyValuePair<Result, UnitAction> AttemptFind = FindUnit();

                //We've won!
                if (AttemptFind.Key == Result.NothingFound)
                {
                    return UnitAction.DoNothing(subjectRef);
                }
                return AttemptFind.Value;

            // Note that even if we can attack from the running position, we don't while running,
            // as we know we can die then.
            case Result.WillDie:
                KeyValuePair<Result, UnitAction> runTo = RunAway();

                // fight to the last! we can't move, so...
                if (runTo.Key == Result.NothingFound)
                {
                    return MinMaxResult.Value;
                }
                return runTo.Value;

            default:
                throw new InvalidProgramException("RunAI: MinMaxResult enum reached invalid state: " + MinMaxResult.Key);
        }
    }
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:50,代码来源:UnitAI.cs

示例4: setDisplayedUnit

 public void setDisplayedUnit(Unit uRef)
 {
     UnitName.text = "Name: " + uRef.name();
     UnitName.color = (uRef.isEnemy()) ? Color.red : Color.black;
     UnitClay.text = "Clay: " + uRef.getClay();
     UnitWater.text = "Water: " + uRef.getCurrentWater();
     UnitBendiness.text = "Bendiness: " + uRef.getBendiness();
     UnitHardness.text = "Hardness: " + uRef.getHardness();
     UnitRangeNotation.text = "Range: [" + uRef.getMinAttackRange() + ", " + uRef.getMaxAttackRange() + "]";
 }
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:10,代码来源:UIManager.cs


注:本文中的Unit.getClay方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。