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


C# Unit.Equals方法代码示例

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


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

示例1: Unit

 public void Unit()
 {
     var u1 = new Unit();
     var u2 = new Unit();
     Assert.IsTrue(u1.Equals(u2));
     Assert.IsFalse(u1.Equals(""));
     Assert.IsFalse(u1.Equals(null));
     Assert.IsTrue(u1 == u2);
     Assert.IsFalse(u1 != u2);
     u1.GetHashCode(); // CHECK
 }
开发者ID:modulexcite,项目名称:IL2JS,代码行数:11,代码来源:UnitTest.cs

示例2: Unit

 public void Unit()
 {
     var u1 = new Unit();
     var u2 = new Unit();
     Assert.True(u1.Equals(u2));
     Assert.False(u1.Equals(""));
     Assert.False(u1.Equals(null));
     Assert.True(u1 == u2);
     Assert.False(u1 != u2);
     Assert.Equal(0, u1.GetHashCode());
     Assert.Equal("()", u1.ToString());
 }
开发者ID:RolandPheasant,项目名称:Rx.NET,代码行数:12,代码来源:UnitTest.cs

示例3: UseMidas

        // --→ Function: Use Midas
        private static void UseMidas(Ability midas, Unit owner)
        {
            if (midas.CanBeCasted() && owner.CanUseItems() && owner.Equals(mHero))
            {
                if (!heroCreateSideMessage)
                {
                    heroCreateSideMessage = true;
                    GenerateSideMessage(GetOwnerName(owner));
                }
                var creeps = ObjectMgr.GetEntities<Creep>().Where(creep => creep.Team != owner.Team && creep.IsAlive && creep.IsVisible && creep.IsSpawned && !creep.IsAncient && creep.Health > 0 && creep.Distance2D(owner) < midas.CastRange + 25).ToList();
                if (!creeps.Any()) return;
                midas.UseAbility(creeps.First());
            }
            else if(heroCreateSideMessage) heroCreateSideMessage = false;

            if (midas.CanBeCasted() && owner.CanUseItems() && owner.ClassID.Equals(ClassID.CDOTA_Unit_SpiritBear))
            {
                if (!bearCreateSideMessage)
                {
                    bearCreateSideMessage = true;
                    GenerateSideMessage(GetOwnerName(owner));
                }
                var creeps = ObjectMgr.GetEntities<Creep>().Where(creep => creep.Team != owner.Team && creep.IsAlive && creep.IsVisible && creep.IsSpawned && !creep.IsAncient && creep.Health > 0 && creep.Distance2D(owner) < midas.CastRange + 25).ToList();
                if (!creeps.Any()) return;
                midas.UseAbility(creeps.First());
            }
            else if(bearCreateSideMessage) bearCreateSideMessage = false;
        }
开发者ID:vitac1998,项目名称:ensagesharp-1,代码行数:29,代码来源:AutoMidas.cs

示例4: addObstacle

 public void addObstacle(Unit unit)
 {
     if(obstacleList == null) {
         obstacleList = new List<Unit>();
     }
     if(!unit.Equals (this)) {
         obstacleList.Add (unit);
     }
 }
开发者ID:noxrawr,项目名称:rts,代码行数:9,代码来源:Customobject.cs

示例5: Cast

        public static bool Cast(Ability ability, Unit target, string name)
        {
            if (name == "item_tango" || name == "item_tango_single")
            {
                if (!target.Equals(AbilityMain.Me))
                {
                    return false;
                }

                var closestTree =
                    ObjectMgr.GetEntities<Tree>()
                        .Where(x => x.IsAlive && x.IsVisible && x.Distance2D(target) < 250)
                        .MinOrDefault(x => x.Distance2D(target));
                if (closestTree == null)
                {
                    return false;
                }

                //Console.WriteLine(closestTree);
                //ability.UseAbility(closestTree);
                //Player.UseAbility(target, ability, closestTree);
                return true;
            }

            if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
            {
                Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
                ManageAutoAttack.AutoAttackDisabled = true;
                SoulRing.Cast(ability);
                ability.UseAbility();
                return true;
            }

            if (name == "abaddon_death_coil" && target.Equals(AbilityMain.Me))
            {
                return false;
            }

            SoulRing.Cast(ability);
            Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
            ManageAutoAttack.AutoAttackDisabled = true;
            ability.UseAbility(target);
            return true;
        }
开发者ID:Ray0fHope,项目名称:EnsageSharp,代码行数:44,代码来源:Heal.cs

示例6: SimpleTargetStrategyFuntionality

 public void SimpleTargetStrategyFuntionality()
 {
     TargetStrategy simpleTargetStrategy = new SimpleTargetStrategy();
     Unit unit = new Unit(100, ArmorType.Unarmored, 10, 10.0, new Vector3(0, 0, 0));
     Unit unit2 = new Unit(100, ArmorType.Unarmored, 10, 10.0, new Vector3(0, 0, 0));
     HashSet<Unit> units = new HashSet<Unit> {unit, unit2};
     Unit returnedUnit = simpleTargetStrategy.GetNextTarget(units);
     Assert.IsNotNull(returnedUnit);
     Assert.IsTrue(unit.Equals(returnedUnit) || unit2.Equals(returnedUnit));
 }
开发者ID:JonasGoldt,项目名称:TDGD_TD,代码行数:10,代码来源:TestTargetStrategy.cs

示例7: OnUnitClicked

    public override void OnUnitClicked(Unit unit)
    {
        if (unit.Equals(_unit) || unit.isMoving)
            return;

        if (_unitsInRange.Contains(unit) && _unit.ActionPoints > 0)
        {
            _unit.DealDamage(unit);
            _cellGrid.CellGridState = new CellGridStateUnitSelected(_cellGrid, _unit);
        }

        if (unit.PlayerNumber.Equals(_unit.PlayerNumber))
        {
            _cellGrid.CellGridState = new CellGridStateUnitSelected(_cellGrid, unit);
        }
            
    }
开发者ID:TheJP,项目名称:GlobalGameJam2016,代码行数:17,代码来源:CellGridStateUnitSelected.cs

示例8: LeastHealthTargetStrategyFuntionality

        public void LeastHealthTargetStrategyFuntionality()
        {
            TargetStrategy leastHealthTargetStrategy = new LeastHealthStrategy();
            Unit unit = new Unit(100, ArmorType.Unarmored, 10, 10.0, new Vector3(0, 0, 0));
            Unit unit2 = new Unit(60, ArmorType.Unarmored, 10, 10.0, new Vector3(0, 0, 0));
            HashSet<Unit> units = new HashSet<Unit> {unit, unit2};
            Unit returnedUnit = leastHealthTargetStrategy.GetNextTarget(units);
            Assert.IsNotNull(returnedUnit);
            Assert.IsTrue(unit2.Equals(returnedUnit));
            units.Remove(unit2);

            returnedUnit = leastHealthTargetStrategy.GetNextTarget(units);
            Assert.IsTrue(unit.Equals(returnedUnit));

            units.Remove(unit);

            returnedUnit = leastHealthTargetStrategy.GetNextTarget(units);
            Assert.IsNull(returnedUnit);
        }
开发者ID:JonasGoldt,项目名称:TDGD_TD,代码行数:19,代码来源:TestTargetStrategy.cs

示例9: Cast

 public static bool Cast(Ability ability, Unit target, string name)
 {
     if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
         ManageAutoAttack.AutoAttackDisabled = true;
         SoulRing.Cast(ability);
         ability.UseAbility();
         return true;
     }
     if ((name == "item_solar_crest" || name == "item_medallion_of_courage") && target.Equals(AbilityMain.Me))
     {
         return false;
     }
     SoulRing.Cast(ability);
     Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 0");
     ManageAutoAttack.AutoAttackDisabled = true;
     ability.UseAbility(target);
     return true;
 }
开发者ID:dendimonster,项目名称:EnsageSharp,代码行数:20,代码来源:Shield.cs

示例10: TryConvertUnit

        public static bool TryConvertUnit(double value, Unit from, Unit to, out double result)
        {
            if (from == null)
                throw new ArgumentNullException ("from");

            if (to == null)
                throw new ArgumentNullException ("to");

            if (!to.Quantity.Equals (from.Quantity)) {
                result = double.NaN;
                return false;
            }

            if (to.Equals (from)) {
                result = value;
                return true;
            }

            result = (value * from.Multiplier) / (to.Multiplier);
            return true;
        }
开发者ID:davidjcaton,项目名称:glowingbrain-data-capture,代码行数:21,代码来源:UnitConversion.cs

示例11: Cast

 public static bool Cast(Ability ability, Unit target, string name)
 {
     if (name == "item_tango" || name == "item_tango_single")
     {
         return false;
         //if (!target.Equals(AbilityMain.Me))
         //{
         //    return false;
         //}
         //var closestTree =
         //    ObjectMgr.GetEntities<Entity>()
         //        .Where(x => x.Name == "ent_dota_tree" && x.Distance2D(target) < 250)
         //        .MinOrDefault(x => x.Distance2D(target)) as Tree;
         //if (closestTree == null)
         //{
         //    return false;
         //}
         //Player.UseAbility(AbilityMain.Me,ability,closestTree);
         //ability.UseAbility(closestTree as Unit);
     }
     if (ability.IsAbilityBehavior(AbilityBehavior.NoTarget, name))
     {
         Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
         ManageAutoAttack.AutoAttackDisabled = true;
         SoulRing.Cast(ability);
         ability.UseAbility();
         return true;
     }
     if (name == "abaddon_death_coil" && target.Equals(AbilityMain.Me))
     {
         return false;
     }
     SoulRing.Cast(ability);
     Game.ExecuteCommand("dota_player_units_auto_attack_after_spell 1");
     ManageAutoAttack.AutoAttackDisabled = true;
     ability.UseAbility(target);
     return true;
 }
开发者ID:dendimonster,项目名称:EnsageSharp,代码行数:38,代码来源:Heal.cs

示例12: OnUnitClicked

    public override void OnUnitClicked(Unit unit)
    {
		Debug.Log ("ZZ");
		if (unit.Equals (_unit) || unit.isMoving) {
			OnStateExit ();
			_cellGrid.CellGridState = new CellGridStateWaitingForInput(_cellGrid);
			return;
		}
		//check if unit is in its reachableEnemyList. if yes move. if no deny player
		if (_unit.GetAvailableDestinations(_cellGrid.Cells).Contains(unit.Cell) && _unit.ActionPoints > 0)
        {
			Debug.LogWarning ("On unit Clicked, attack this enemy");
			//_unit.Move(unit.Cell,_unit.FindPath(_cellGrid.Cells, unit.Cell));
			_unit.Move(unit.Cell,_unit.FindPath(_unit.GetAvailableDestinations(_cellGrid.Cells), unit.Cell));
			_cellGrid.EndTurn ();
        }

        if (unit.PlayerNumber.Equals(_unit.PlayerNumber))
        {
			Debug.LogWarning ("select another sa piece");
            _cellGrid.CellGridState = new CellGridStateUnitSelected(_cellGrid, unit);
        }
            
    }
开发者ID:pujarisahil,项目名称:Shinsa,代码行数:24,代码来源:CellGridStateUnitSelected.cs

示例13: canWalkTo

 /// <summary>
 /// Returns true if a unit can walk to the given node with current endurance values.
 /// </summary>
 internal bool canWalkTo(Unit u, Node node)
 {
     if (u.Equals(currentUnit))
         return unitRef.getAccessibleNodesSet().Contains(node);
     return enemyMemoizer[u].getAccessibleNodesSet().Contains(node);
 }
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:9,代码来源:PathManager.cs

示例14: getNodesInRange

 /// <summary>
 /// Get the current list of nodes in range for a given unit.
 /// </summary>
 /// <param name="u">Unit to query.</param>
 /// <returns>The list of all positions in range of unit.</returns>
 public List<Node> getNodesInRange(Unit u)
 {
     if (u.Equals(currentUnit))
         return unitRef.getNodesInRange(u);
     return enemyMemoizer[u].getNodesInRange(u);
 }
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:11,代码来源:PathManager.cs

示例15: maxDamageMoveCost

 /// <summary>
 /// Returns the move cost of the maximum damage move (closest move that can attack a square, actually).
 /// </summary>
 internal int maxDamageMoveCost(Unit u, Node node)
 {
     if (u.Equals(currentUnit))
         return unitRef.minCostToAttackSquare(node);
     return enemyMemoizer[u].minCostToAttackSquare(node);
 }
开发者ID:punster94,项目名称:AI-for-Game-Design,代码行数:9,代码来源:PathManager.cs


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