Inheritance: MonoBehaviour
コード例 #1
0
	/// <summary>
	/// 初始化公用数据
	/// </summary>
	public void initData()
	{
		if (gameObject != null) 
		{
			m_unit = gameObject.GetComponent<Unit>();
		}
	}
コード例 #2
0
ファイル: AIFaction.cs プロジェクト: urgamedev/TurnBasedGame
 public float evaluate(Tile tile,Unit unit)
 {
     float value = 0f;
         value += positionValue(tile,unit);
         value += attackValue(tile,unit);
     return value;
 }
コード例 #3
0
ファイル: PrintHelper.cs プロジェクト: baotiit/savvyplatform
 public static void PrintWebControl(Control ctrl, string Script)
 {
     StringWriter stringWrite = new StringWriter();
     System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
     if (ctrl is WebControl)
     {
         Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
     }
     Page pg = new Page();
     pg.EnableEventValidation = false;
     if (Script != string.Empty)
     {
         pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
     }
     HtmlForm frm = new HtmlForm();
     pg.Controls.Add(frm);
     frm.Attributes.Add("runat", "server");
     frm.Controls.Add(ctrl);
     pg.DesignerInitialize();
     pg.RenderControl(htmlWrite);
     string strHTML = stringWrite.ToString();
     HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.Write(strHTML);
     HttpContext.Current.Response.Write("<script>window.print();</script>");
     HttpContext.Current.Response.End();
 }
コード例 #4
0
ファイル: Chakram.cs プロジェクト: IdcNoob/Ensage
 public void AddModifierObstacle(Modifier modifier, Unit unit)
 {
     if (Obstacle != null)
     {
         End();
     }
 }
コード例 #5
0
ファイル: Tornado.cs プロジェクト: IdcNoob/Ensage
 public void AddUnit(Unit unit)
 {
     abilityUnit = unit;
     StartCast = Game.RawGameTime;
     EndCast = Game.RawGameTime + GetCastRange() / GetProjectileSpeed();
     StartPosition = unit.Position;
 }
コード例 #6
0
ファイル: BlinkAbility.cs プロジェクト: IdcNoob/Ensage
        public override void Use(EvadableAbility ability, Unit target)
        {
            var range = GetCastRange() - 60;
            BlinkPosition = Hero.NetworkPosition.Extend(BlinkPosition, range);
            var obtsacles = Pathfinder.GetIntersectingObstacles(BlinkPosition, Hero.HullRadius);

            if (obtsacles.Any())
            {
                bool success;
                BlinkPosition =
                    Pathfinder.CalculatePathFromObstacle(BlinkPosition, BlinkPosition, 5, out success).LastOrDefault();

                if (!success)
                {
                    //gg
                    return;
                }

                if (Hero.Distance2D(BlinkPosition) > range)
                {
                    // probably gg
                    BlinkPosition = Hero.NetworkPosition.Extend(BlinkPosition, range);
                }
            }

            Ability.UseAbility(BlinkPosition);
            Sleep();
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: IdcNoob/Ensage
        private static bool CheckTarget(Unit enemy, bool doubleOwnage = false)
        {
            if (enemy.IsIllusion || !enemy.IsValidTarget(dagon.GetCastRange(), true, hero.NetworkPosition))
            {
                return false;
            }

            if (enemy.IsLinkensProtected() || enemy.IsMagicImmune())
            {
                return false;
            }

            if (!enemy.CanDie() || enemy.Modifiers.Any(x => IgnoreModifiers.Any(x.Name.Equals)))
            {
                return false;
            }

            var damage = AbilityDamage.CalculateDamage(dagon, hero, enemy);

            if (doubleOwnage)
            {
                damage *= 2;
            }

            return enemy.Health < damage;
        }
コード例 #8
0
    Unit[] toUnits(Parameter.Stage stage)
    {
        var units = new List<Unit>();
        foreach (var enemy in stage.Enemies)
        {
            var job = enemy.Job;
            for(var i=0; i<enemy.Count; ++i)
            {
                var unit = new Unit(false, job.Hp, job.Attack, job.Defence, job.Move);
                units.Add(unit);
            }
        }

        var ps = stage.Formation.Positions;
        int len = stage.Formation.Positions.Length;
        for(int i=0; i<units.Count; ++i)
        {
            var p = ps[i % len];
            units[i].Leader = i < len ? ps[i].Leader : false;
            units[i].X = p.X;
            units[i].Y = p.Y;
        }

        return units.ToArray ();
    }
コード例 #9
0
	public override void RunEffect(Unit u, bool reapply = false)
	{
		base.RunEffect(u, reapply);

		//give shield
		u.shield += shieldAmount;
	}
コード例 #10
0
ファイル: paging_tests.cs プロジェクト: asgerhallas/DomFx
        protected Line ChildElement(Unit left = default(Unit),
            Unit top = default(Unit),
            Unit innerHeight = default(Unit),
            bool breakable = false,
            bool followLineHeight = false,
            Unit border = default(Unit),
            bool keepWithNextLine = false,
            Behaviors behavior = null,
            IEnumerable<Line> children = null)
        {
            LayoutedElement element;
            if (children == null)
            {
                element = new LayoutedElement(new TestSpecification(), Children.Empty);
            }
            else
            {
                element = new LayoutedElement(new TestSpecification(), new Children(children.GroupBy(x => x.Top).SelectMany(x => x)));
            }

            element.Left = left;
            element.ForcedInnerHeight = innerHeight;
            element.Specification.FollowLineHeight = followLineHeight;
            element.Specification.Breakable = breakable;
            element.Specification.Margins = new Margins { Bottom = border, Left = border, Right = border, Top = border };
            element.Specification.Behavior = behavior ?? new NullBehavior();

            return new Line(top, keepWithNextLine, element);
        }
コード例 #11
0
ファイル: paging_tests.cs プロジェクト: asgerhallas/DomFx
        protected Line Element(Unit left = default(Unit),
            Unit top = default(Unit),
            Unit innerHeight = default(Unit),
            bool breakable = false,
            bool followLineHeight = false,
            Unit border = default(Unit),
            bool keepWithNextLine = false,
            Behaviors behavior = null,
            IEnumerable<Line> children = null)
        {
            // Top offsets are not allowed in real usage, so we fake one by adding an element
            if (lines.Count == 0 && top > 0.cm())
            {
                lines.Add(new Line(0.cm(), false, new LayoutedElement(new TestSpecification
                {
                    Breakable = true,
                    OrphanHeight = 0.cm(),
                    WidowHeight = 0.cm()
                }, Children.Empty)
                {
                    Name = "Spacer",
                    ForcedInnerHeight = top,
                }));
            }

            var line = ChildElement(left, top, innerHeight, breakable, followLineHeight, border, keepWithNextLine, behavior, children);
            lines.Add(line);
            return line;
        }
コード例 #12
0
 public void Show(Unit Unit)
 {
     if(Unit == null)
         return;
     m_Unit = Unit;
     base.Show(true);
 }
コード例 #13
0
 protected override void ReportGauge(string name, double value, Unit unit, MetricTags tags)
 {
     if (!double.IsNaN(value) && !double.IsInfinity(value))
     {
         Pack(name, value, tags);
     }
 }
コード例 #14
0
 public CellGridStateUnitSelected(CellGrid cellGrid, Unit unit)
     : base(cellGrid)
 {
     _unit = unit;
     _pathsInRange = new List<Cell>();
     _unitsInRange = new List<Unit>();
 }
コード例 #15
0
 void OnEnable()
 {
     Owner = GetComponent<Unit>();
     MainController.Instance.FocusedUnit = Owner;
     MainController.Instance.SwitchSkill(0);
     MainController.Instance.MoveControlPad.Init(Owner);
 }
コード例 #16
0
ファイル: AI.cs プロジェクト: scienide00/MayaRoguelike
        public static int DrunkardWalk(Unit unit)
        {
            MersenneTwister mt = new MersenneTwister();
            unit.MakeAMove((CardinalDirection)mt.Next(9));

            return 100;
        }
コード例 #17
0
ファイル: UnitMgr.cs プロジェクト: seonwifi/bongbong
    public void AddEnermy(Unit addUnit)
    {
        bool b_set = false;

        addUnit.m_ai.m_TeamType = eUnitType.Enermy;

        for (int i = 0; i < m_enermyUnitList.Count; ++i)
        {
            if(m_enermyUnitList[i] == null)
            {
                m_enermyUnitList[i] = addUnit;
                b_set = true;
                break;
            }
        }
        if(b_set == false)
        {
            m_enermyUnitList.Add(addUnit);
        }

        if(NewUnitCall != null)
        {
            NewUnitCall(addUnit);
        }
    }
コード例 #18
0
ファイル: GameState.cs プロジェクト: Keldyn/BattleOfTheClans
 public static void DisplayScrollingCombatText(Unit unit, String text, ClientCommon.Font font)
 {
     Vector3 pos = Vector3.Project(unit.Position,
         Program.Instance.Device.Viewport.X,
         Program.Instance.Device.Viewport.Y,
         Program.Instance.Device.Viewport.Width,
         Program.Instance.Device.Viewport.Height,
         Program.Instance.Device.Viewport.MinZ,
         Program.Instance.Device.Viewport.MaxZ,
         GameScene.Camera.View * GameScene.Camera.Projection);
     Control f;
     scrollingCombatTexts.Add(new ScrollingCombatText
     {
         Timeout = 1,
         Unit = unit,
         Text = f = new Control(Program.Instance.InterfaceManager)
         {
             Size = new Vector2(300, 100),
             Background = new TextGraphic(Program.Instance.GlyphCache)
             {
                 Text = text,
                 Font = font,
                 Anchor = Orientation.Bottom
             }
         }
     });
     f.Position = pos - new Vector3(f.Size.X/2, f.Size.Y, 0);
     Program.Instance.InterfaceManager.Add(f);
 }
コード例 #19
0
ファイル: ExtendedMessage.cs プロジェクト: gerzo/x10
 /// <summary>
 /// Creates new X10 extended message.
 /// </summary>
 /// <param name="house">Valid range is A-P.</param>
 /// <param name="unit">Valid units are 01-16.</param>
 /// <param name="command">Only commands ExtendedCode and ExtendedData are valid for extended messages.</param>
 /// <param name="extendedCommand">Byte 0-255. Make sure that either extended command or data is above 0.</param>
 /// <param name="extendedData">Byte 0-255. Make sure that either extended command or data is above 0.</param>
 public ExtendedMessage(House house, Unit unit, Command command, byte extendedCommand, byte extendedData)
     : base(house, unit, command)
 {
     Validate(extendedCommand, extendedData);
     ExtendedCommand = extendedCommand;
     ExtendedData = extendedData;
 }
コード例 #20
0
ファイル: Tombstone.cs プロジェクト: IdcNoob/Ensage
        public Tombstone(Unit unit)
        {
            this.unit = unit;
            PositionCorrection = new Vector2(25);
            var level = (uint)char.GetNumericValue(unit.Name.Last());
            Radius =
                Ability.GetAbilityDataByName(AbilityName)
                    .AbilitySpecialData.First(x => x.Name == "radius")
                    .GetValue(level - 1);
            Duration =
                Ability.GetAbilityDataByName(AbilityName)
                    .AbilitySpecialData.First(x => x.Name == "duration")
                    .GetValue(level - 1);
            Position = unit.Position;
            Texture = Drawing.GetTexture("materials/ensage_ui/other/tombstone");
            Handle = unit.Handle;
            TextureSize = new Vector2(40);
            EndTime = Game.RawGameTime + Duration;
            ShowTimer = Menu.TimerEnabled(AbilityName);

            if (Menu.RangeEnabled(AbilityName))
            {
                ParticleEffect = new ParticleEffect("particles/ui_mouseactions/drag_selected_ring.vpcf", Position);
                ParticleEffect.SetControlPoint(1, new Vector3(128, 128, 128));
                ParticleEffect.SetControlPoint(2, new Vector3(Radius, 255, 0));
            }
        }
コード例 #21
0
	// 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();
    }
コード例 #22
0
 public void CancelBuildingPlacement()
 {
     findingPlacement = false;
     Destroy(tempBuilding.gameObject);
     tempBuilding = null;
     tempCreator = null;
 }
コード例 #23
0
        public void OneUnitDefaultName()
        {
            var meter = new Unit("meter");
            var oneMeter = new Measurement(meter, 1M);

            oneMeter.ToString().Should().Be("1 meter");
        }
コード例 #24
0
 public void OunceAndPound(Unit unit, Unit servingSizeUnit)
 {
     sut.Unit = unit;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsTrue(sut.AreNutrientsPer100gUsable);
     Assert.IsFalse(sut.AreNutrientsPerServingUsable);
     product.ServingSizeValue = 1;
     product.ServingSizeUnit = servingSizeUnit;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsTrue(sut.AreNutrientsPer100gUsable);
     Assert.IsTrue(sut.AreNutrientsPerServingUsable);
     product.EnergyPerServing = 0;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsTrue(sut.AreNutrientsPer100gUsable);
     Assert.IsFalse(sut.AreNutrientsPerServingUsable);
     sut.Unit = Unit.ServingSize;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsTrue(sut.AreNutrientsPer100gUsable);
     Assert.IsFalse(sut.AreNutrientsPerServingUsable);
     product.EnergyPerServing = 100;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsFalse(sut.AreNutrientsPer100gUsable);
     Assert.IsTrue(sut.AreNutrientsPerServingUsable);
     product.EnergyPer100g = 0;
     sut.Unit = unit;
     Assert.IsTrue(sut.AnyNutrientsPerUnitPresent);
     Assert.IsFalse(sut.AreNutrientsPer100gUsable);
     Assert.IsTrue(sut.AreNutrientsPerServingUsable);
 }
コード例 #25
0
 //Cancel the currently displayed action
 public void CancelAction()
 {
     selectedUnit = null;
     m_tiles.ClearSelectedTiles();
     m_hud.HideUnitInfo();
     e_playerState = PlayerState.Default;
 }
コード例 #26
0
ファイル: Utils.cs プロジェクト: Esk0r/Ensage.Common
 public static bool ChainStun(Unit unit, double delay, string except, bool onlychain)
 {
     var chain = false;
     var stunned = false;
     string[] modifiersList =
     {
         "modifier_shadow_demon_disruption", "modifier_obsidian_destroyer_astral_imprisonment_prison",
         "modifier_eul_cyclone", "modifier_invoker_tornado", "modifier_bane_nightmare",
         "modifier_shadow_shaman_shackles",
         "modifier_crystal_maiden_frostbite", "modifier_ember_spirit_searing_chains",
         "modifier_axe_berserkers_call",
         "modifier_lone_druid_spirit_bear_entangle_effect", "modifier_meepo_earthbind",
         "modifier_naga_siren_ensnare",
         "modifier_storm_spirit_electric_vortex_pull", "modifier_treant_overgrowth", "modifier_cyclone",
         "modifier_sheepstick_debuff", "modifier_shadow_shaman_voodoo", "modifier_lion_voodoo",
         "modifier_brewmaster_storm_cyclone",
         "modifier_puck_phase_shift", "modifier_dark_troll_warlord_ensnare",
         "modifier_invoker_deafening_blast_knockback"
     };
     var modifiers = unit.Modifiers.OrderByDescending(x => x.RemainingTime);
     foreach (var m in modifiers.Where(m => (m.IsStunDebuff || modifiersList.Contains(m.Name)) && (except == null || m.Name == except)))
     {
         stunned = true;
         var remainingTime = m.RemainingTime;
         if (m.Name == "modifier_eul_cyclone" || m.Name == "modifier_invoker_tornado")
             remainingTime += 0.07f;
         chain = remainingTime <= delay;
     }
     return ((((!(stunned || unit.IsStunned()) || chain) && !onlychain) || (onlychain && chain)));
 }
コード例 #27
0
ファイル: Attack.cs プロジェクト: murrain/Snowshoes
 public static bool AttackUnit(Unit unit, TimeSpan timeout)
 {
     if (unit.Type == UnitType.Monster
         && unit.GetAttributeInteger(UnitAttribute.Is_NPC) == 0
         && unit.GetAttributeInteger(UnitAttribute.Is_Helper) == 0
         && unit.GetAttributeInteger(UnitAttribute.Invulnerable) == 0)
     {
         switch (Me.SNOId)
         {
             case SNOActorId.Barbarian_Male:
             case SNOActorId.Barbarian_Female:
                 //return Classes.Barbarian.AttackUnit(unit, timeout);
                 break;
             case SNOActorId.WitchDoctor_Male:
             case SNOActorId.WitchDoctor_Female:
                 //return Classes.WitchDoctor.AttackUnit(unit, timeout);
                 break;
             case SNOActorId.Wizard_Male:
             case SNOActorId.Wizard_Female:
                 //return Classes.Wizard.AttackUnit(unit, timeout);
                 break;
             case SNOActorId.Demonhunter_Male:
             case SNOActorId.Demonhunter_Female:
                 return DemonHunter.AttackUnit(unit, timeout);
             case SNOActorId.Monk_Male:
             case SNOActorId.Monk_Female:
                 return Monk.AttackUnit(unit, timeout);
         }
     }
     return false;
 }
コード例 #28
0
    protected override void OnShow()
    {
        if(m_Unit == null)
            m_Unit = base.Player.CurrentPartyUnit;

        Prepare();
    }
コード例 #29
0
ファイル: AliveUnitState.cs プロジェクト: Chirimorin/DuckHunt
        public override void Update(Unit unit, IGame game)
        {
            base.Update(unit, game);

            if ((game.Time - unit.BirthTime) > FleeTime)
                unit.setState(UnitFactories.States.Create(unit.Name, "fleeing"), game);
        }
コード例 #30
0
ファイル: iUtility.cs プロジェクト: ehmehe/Ensage
 public static void Cast(this Ability ability, Unit unit)
 {
     if (ability.IsReady() && unit.IsValidTarget(ability.CastRange))
     {
         ability.UseAbility(unit);
     }
 }
コード例 #31
0
    public void UltraWebGrid1_InitializeLayout(object sender,
                                               Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
    {
        string[] ItemId = ItemIds.Split(',');
        foreach (Infragistics.WebUI.UltraWebGrid.UltraGridColumn c in e.Layout.Bands[0].Columns)
        {
            c.Width = Unit.Pixel(10);
            c.Header.ClickAction           = HeaderClickAction.Select;
            c.Header.Style.HorizontalAlign = HorizontalAlign.Center;
            c.Header.Style.VerticalAlign   = VerticalAlign.Middle;
            c.Header.Style.Font.Bold       = true;
            c.AllowResize    = AllowSizing.NotSet;
            c.AllowUpdate    = AllowUpdate.No;
            c.CellStyle.Wrap = true;
            if (c.Key.Equals("ContainerName"))
            {
                c.Header.RowLayoutColumnInfo.SpanY = 2;
            }
            else
            {
                c.Header.RowLayoutColumnInfo.OriginY = 1;
            }
            if (c.Key.Contains("~"))
            {
                c.Header.Caption = c.Key.Split('~')[1];
            }
            if (c.Key.Contains("ChunkValue"))
            {
                c.Width = Unit.Pixel(300);
            }
        }
        objDT_ItemName = new DataTable();
        objDT_ItemName.Columns.Add("ItemName");
        DataRow[] drCurrent = null;
        for (int i = 0; i < ItemId.Length; i++)
        {
            DataRow dr = objDT_ItemName.NewRow();
            drCurrent = objDS.Tables[0].Select("ItemId = '" + ItemId[i] + "'");
            if (drCurrent[0]["LevelId"].ToString().Equals("7"))
            {
                dr["ItemName"] = drCurrent[0]["ItemNumber"] + " [" + drCurrent[0]["LevelName"].ToString() + "]";
            }
            else
            {
                dr["ItemName"] = drCurrent[0]["ItemName"] + " [" + drCurrent[0]["LevelName"].ToString() + "]";
            }
            objDT_ItemName.Rows.Add(dr);
        }
        objDT_ItemName.AcceptChanges();
        int count       = 1;
        int headerindex = 0;

        foreach (DataRow r in objDT_ItemName.Rows)
        {
            Infragistics.WebUI.UltraWebGrid.ColumnHeader ch = new ColumnHeader(true);
            ch.Style.Width                 = Unit.Pixel(0);
            ch.Caption                     = r["ItemName"].ToString();
            ch.Style.HorizontalAlign       = HorizontalAlign.Center;
            ch.Style.VerticalAlign         = VerticalAlign.Middle;
            ch.Style.Font.Bold             = true;
            ch.Style.Width                 = Unit.Pixel(330);
            ch.RowLayoutColumnInfo.OriginY = 0;
            ch.RowLayoutColumnInfo.OriginX = count;
            ch.RowLayoutColumnInfo.SpanX   = 4;
            //count takes care of SpanX for the ItemName/ItemNumber Header
            count = ch.RowLayoutColumnInfo.OriginX + ch.RowLayoutColumnInfo.SpanX;
            e.Layout.Bands[0].HeaderLayout.Add(ch);
        }
    }
コード例 #32
0
ファイル: Unit.cs プロジェクト: UnMapache/VT_DEMO
            public static double DrawConvertedSizeField(string label, double size, Unit storeAs, Unit displayAs, float minWidth)
            {
                size = Convert(storeAs, displayAs, size);
#if UNITY_5
                size = EditorGUILayout.DoubleField(label, size, GUILayout.MinWidth(minWidth));
#else
                size = EditorGUILayout.FloatField(label, (float)size, GUILayout.MinWidth(minWidth));
#endif
                return(Convert(displayAs, storeAs, size));
            }
コード例 #33
0
 public void SetUnit(Unit unit)
 {
     SetUnit(unit, false);
 }
コード例 #34
0
 public void PreInitialize()
 {
     genericUnitPrefab = Resources.Load <Unit>("Prefabs/Units/GenericUnit");
     unitDictionnary   = new Dictionary <Vector3Int, Unit>();
 }
コード例 #35
0
 /// <summary>
 /// Check the Unit Type and return true if the Type T passed is equals to it
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="unit"></param>
 /// <returns></returns>
 public bool CheckUnitType <T>(Unit unit) where T : class
 {
     return(unit.GetType().Equals(typeof(T)));
 }
コード例 #36
0
 /// <summary>
 /// Sets the Position from a Unit.
 /// </summary>
 private void SetFromUnit(Unit unit)
 {
     this.shapePosition = ShapePosition.Undefined;
     this.position      = unit;
 }
コード例 #37
0
 /// <summary>
 /// Initializes a new instance of the LeftPosition class from Unit.
 /// </summary>
 private LeftPosition(Unit value)
 {
     this.shapePosition = ShapePosition.Undefined;
     this.position      = value;
     this.notNull       = !value.IsNull;
 }
コード例 #38
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override void PassengerBoarded(Unit passenger, sbyte seatId, bool apply)
 {
     GetScript().ProcessEventsFor(apply ? SmartEvents.PassengerBoarded : SmartEvents.PassengerRemoved, passenger, (uint)seatId, 0, apply);
 }
コード例 #39
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override void IsSummonedBy(Unit summoner)
 {
     GetScript().ProcessEventsFor(SmartEvents.JustSummoned, summoner);
 }
コード例 #40
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker)
 {
     if (invoker != null)
         GetScript().mLastInvoker = invoker.GetGUID();
     GetScript().SetScript9(e, entry);
 }
コード例 #41
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override void SpellHitTarget(Unit target, SpellInfo spell)
 {
     GetScript().ProcessEventsFor(SmartEvents.SpellhitTarget, target, 0, 0, false, spell);
 }
コード例 #42
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override void DamageDealt(Unit victim, ref uint damage, DamageEffectType damageType)
 {
     GetScript().ProcessEventsFor(SmartEvents.DamagedTarget, victim, damage);
 }
コード例 #43
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override void KilledUnit(Unit victim)
 {
     GetScript().ProcessEventsFor(SmartEvents.Kill, victim);
 }
コード例 #44
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override void HealReceived(Unit by, uint addhealth)
 {
     GetScript().ProcessEventsFor(SmartEvents.ReceiveHeal, by, addhealth);
 }
コード例 #45
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override void SpellHit(Unit unit, SpellInfo spellInfo)
 {
     GetScript().ProcessEventsFor(SmartEvents.SpellHit, unit, 0, 0, false, spellInfo);
 }
コード例 #46
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override void SpellHit(Unit caster, SpellInfo spell)
 {
     GetScript().ProcessEventsFor(SmartEvents.SpellHit, caster, 0, 0, false, spell);
 }
コード例 #47
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 public virtual void OnSpellClick(Unit clicker, ref bool result)
 {
 }
コード例 #48
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override bool CanAIAttack(Unit victim)
 {
     return !me.HasReactState(ReactStates.Passive);
 }
コード例 #49
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 // Called when owner attacks something
 public virtual void OwnerAttacked(Unit target)
 {
 }
コード例 #50
0
ファイル: SmartAI.cs プロジェクト: PeterG75/CypherCore
 public override void OnLootStateChanged(uint state, Unit unit)
 {
     GetScript().ProcessEventsFor(SmartEvents.GoLootStateChanged, unit, state);
 }
コード例 #51
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 // Called when the creature is target of hostile action: swing, hostile spell landed, fear/etc)
 public virtual void AttackedBy(Unit attacker)
 {
 }
コード例 #52
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 public virtual void PassengerBoarded(Unit passenger, sbyte seatId, bool apply)
 {
 }
コード例 #53
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 // Called when hit by a spell
 public virtual void SpellHit(Unit caster, SpellInfo spell)
 {
 }
コード例 #54
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 // Called when owner takes damage
 public virtual void OwnerAttackedBy(Unit attacker)
 {
 }
コード例 #55
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 public virtual void IsSummonedBy(Unit summoner)
 {
 }
コード例 #56
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 // Called when spell hits a target
 public virtual void SpellHitTarget(Unit target, SpellInfo spell)
 {
 }
コード例 #57
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 // Called when the creature kills a unit
 public virtual void KilledUnit(Unit victim)
 {
 }
コード例 #58
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 public virtual void SummonedCreatureDies(Creature summon, Unit killer)
 {
 }
コード例 #59
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
 // Called when the creature is killed
 public virtual void JustDied(Unit killer)
 {
 }
コード例 #60
0
ファイル: CreatureAI.cs プロジェクト: snowflake95/CypherCore
        public void DoZoneInCombat(Creature creature = null, float maxRangeToNearestTarget = 250.0f)
        {
            if (!creature)
            {
                creature = me;
            }

            if (!creature.CanHaveThreatList())
            {
                return;
            }

            Map map = creature.GetMap();

            if (!map.IsDungeon())                                  //use IsDungeon instead of Instanceable, in case Battlegrounds will be instantiated
            {
                Log.outError(LogFilter.Server, "DoZoneInCombat call for map that isn't an instance (creature entry = {0})", creature.IsTypeId(TypeId.Unit) ? creature.ToCreature().GetEntry() : 0);
                return;
            }

            if (!creature.HasReactState(ReactStates.Passive) && creature.GetVictim() == null)
            {
                Unit nearTarget = creature.SelectNearestTarget(maxRangeToNearestTarget);
                if (nearTarget != null)
                {
                    creature.GetAI().AttackStart(nearTarget);
                }
                else if (creature.IsSummon())
                {
                    Unit summoner = creature.ToTempSummon().GetSummoner();
                    if (summoner != null)
                    {
                        Unit target = summoner.GetAttackerForHelper();
                        if (target == null && summoner.CanHaveThreatList() && !summoner.GetThreatManager().IsThreatListEmpty())
                        {
                            target = summoner.GetThreatManager().GetHostilTarget();
                        }
                        if (target != null && (creature.IsFriendlyTo(summoner) || creature.IsHostileTo(target)))
                        {
                            creature.GetAI().AttackStart(target);
                        }
                    }
                }
            }

            // Intended duplicated check, the code above this should select a victim
            // If it can't find a suitable attack target then we should error out.
            if (!creature.HasReactState(ReactStates.Passive) && creature.GetVictim() == null)
            {
                Log.outError(LogFilter.Server, "DoZoneInCombat called for creature that has empty threat list (creature entry = {0})", creature.GetEntry());
                return;
            }

            var playerList = map.GetPlayers();

            if (playerList.Empty())
            {
                return;
            }

            foreach (var player in playerList)
            {
                if (player.IsGameMaster())
                {
                    continue;
                }

                if (player.IsAlive())
                {
                    creature.SetInCombatWith(player);
                    player.SetInCombatWith(creature);
                    creature.AddThreat(player, 0.0f);
                }

                /* Causes certain things to never leave the threat list (Priest Lightwell, etc):
                 * foreach (var unit in player.m_Controlled)
                 * {
                 *  me.SetInCombatWith(unit);
                 *  unit.SetInCombatWith(me);
                 *  me.AddThreat(unit, 0.0f);
                 * }*/
            }
        }