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


C# Unit.getMaxAttackRange方法代码示例

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


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

示例1: 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

示例2: displayRangeOfUnit

		public void displayRangeOfUnit(Unit u, Vector2 mousePosition)
        {
            clearRangeDisplay();

            if (overlayNodes == null)
				overlayNodes = new List<Node>();
            
			List<Node> reach = nodesWithinEnduranceValue(closestMostValidNode(mousePosition), u.getCurrentWater());
            List<Node> range = NodesInRangeOfNodes(reach, u.getMinAttackRange(), u.getMaxAttackRange());
            
            HashSet<Node> inReach = new HashSet<Node>();
			inReach.UnionWith(reach);
			HashSet<Node> inRange = new HashSet<Node>();
			inRange.UnionWith(range);
			inRange.RemoveWhere(inReach.Contains);

			foreach (Node n in inReach)
			{
				//make slightly smaller to show square off
				Node q = new Node(transform.gameObject, nodeImg, n.getPos(), n.getGridPos(), Node.randWalkState(), radii * 1.75f);
				q.setColor(new Color(0, 0.5f, 0, 0.75f));

				overlayNodes.Add(q);
			}
            
			foreach (Node n in inRange)
			{
				//make slightly smaller to show square off
				Node q = new Node(transform.gameObject, nodeImg, n.getPos(), n.getGridPos(), Node.randWalkState(), radii * 1.75f);
				q.setColor(new Color(0, 0, 0.5f, 0.75f));

				overlayNodes.Add(q);
			}
		}
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:34,代码来源:PathFinder.cs

示例3: takeAttackFrom

	// Takes the attack from an enemy unit, returning the counter-attack and attack results.
    // TODO: fix this weird attack problem
    // on counters it attacks itself?
	public List<AttackResult> takeAttackFrom(Unit enemy, int distance, bool firstAttack)
    {
        Attack atk = new Attack(enemy, this);

        List<AttackResult> attacks = new List<AttackResult>();
		AttackResult result = new AttackResult(HitType.Miss, 0, false, atk);
		AttackResult counter = new AttackResult(HitType.CannotCounter, 0, false);

        string statStr = "stats1 this " + ident() + ", clay: " + clay + ", endurance: " + currentWater;
        statStr += "\nstats1 enemy " + enemy.ident() + ", clay: " + enemy.clay + ", endurance: " + currentWater;
        statStr += "\nAttack info: " + atk;
        Debug.Log(statStr);

        Debug.Log("taking attack from: " + ident() + ", enemy doing this: " + enemy.ident());
        string playType = (isEnemy()) ? "enemy" : "player";

        if (Random.value <= atk.getHitChance())
        {
            result.setType(HitType.Hit);
            result.setDamageTaken(atk.getDamage());

            Debug.Log(playType + " was Hit!");

            if (Random.value <= atk.getCritChance())
            {
                clay -= (3 * atk.getDamage());

                result.setType(HitType.Crit);
                result.setDamageTaken(3 * atk.getDamage());
                Debug.Log("Crit!");
            }
            else
                clay -= atk.getDamage();
        }
        else
            Debug.Log(playType + " was Missed!");

		if(clay <= 0)
			result.setKilled(true);
		// Only counter if it is the first attack in a set and the enemy's range allows it
		else if(firstAttack && enemy.getMinAttackRange() <= distance && enemy.getMaxAttackRange() >= distance)
			counter = enemy.takeAttackFrom(this, distance, false)[0];

		// Add this enemy's result first, then the counter result
		attacks.Add(result);
		attacks.Add(counter);

        statStr = "\nstats2 this " + ident() + ", clay: " + clay + ", endurance: " + currentWater;
        statStr += "\nstats2 enemy " + enemy.ident() + ", clay: " + enemy.clay + ", endurance: " + currentWater;
        Debug.Log(statStr);
        return attacks;
	}
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:55,代码来源:Unit.cs


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