示例#1
0
 // Start is called before the first frame update
 void Start()
 {
     state = CombatState.NULL;
     ccs   = FindObjectsOfType <CharCombat>();
     _ct   = FindObjectOfType <CombatTimer>();
     _cd   = FindObjectOfType <CharDistance>();
 }
示例#2
0
 void Start()
 {
     runes       = GameObject.FindGameObjectsWithTag(runeTag);
     runesParent = GameObject.Find("Runes").transform;
     SlotMaster.RunesAvailable += OnRunesAvailable;
     Player.TookDamage         += OnPlayerTookDamage;
     slotMaster    = GameObject.Find("Slots").GetComponent <SlotMaster>();
     combatTimer   = GameObject.Find("Timer").GetComponent <CombatTimer>();
     runeInventory = FindObjectOfType <RuneInventory>();
     enemy         = FindObjectOfType <Enemy>();
     player        = FindObjectOfType <Player>();
     Player.Died  += OnPlayerDied;
     Enemy.Died   += OnEnemyDied;
 }
示例#3
0
    public override void _Ready()
    {
        c.Reset();

        //! Note I have no idea what the next comments are, they just are
        //? Update 4 months later: I think these are talking about the current_round line which was just there to test the end-conquest screen
        //? and how it a) must be done in this file and not combatinfo.cs and b) it leads to a visual glitch in the round counter but whatever
        // can't put that in reset() since otherwise it would do that between rounds
        // note: this executes AFTER RoundCounter grabs the data, so...
        //	CombatInfo.current_round = 3

        CombatTimer = (CombatTimer)FindNode("CombatTimer");

        Events.roundWon += OnRoundWon;
        Events.newRound += OnNewRound;

        Events.conquestLost += OnConquestLost;
        Events.conquestWon  += OnConquestWon;
    }
示例#4
0
		//static int aaa = 0;
		void OnCombatTick( CombatTimer from )
		{
			combatTimer.Delay = activeWeapon.Delay;
			if ( AttackTarget == null || from.target != AttackTarget.Guid )
			{
				StopAttacking();
				from.Stop();
				return;
			}
			TimeSpan ts = DateTime.Now.Subtract( last );

			if ( AttackTarget == null )
			{
				StopAttacking();
				return;
			}
			if ( AttackTarget.Dead )
			{
				StopAttacking();
				AttackTarget = null;
			}
			if ( AttackTarget is BaseCreature )
				AttackTarget.UpdateXYZ();
			if ( Mobile.GetDirection( this as Mobile, AttackTarget ) != Pos.Front )
			{
				account.ToAllPlayerNear( OpCodes.SMSG_ATTACKSWING_BADFACING, tempBuff, 4 );
				return;
			}
			float dist = Distance( AttackTarget );
			
			lastDistance = dist;

			if ( dist < 11 * ( AttackTarget.CombatReach + CombatReach ) )
			{
				
				if(this.AttackTarget != null)
				{
					ArrayList arr1 = new ArrayList();
					foreach(NextAttackEffect nae in this.NextAttackEffects)
					{
						
						bool ok = false;
						this.OnSpellTemplateResults(nae.spell,this.AttackTarget);
						this.NextAttackSpellGo( nae );
						this.SpellSuccess();
						if(nae.onEffect is NextAttackEffectDelegate)
						{
							NextAttackEffectDelegate naed = (NextAttackEffectDelegate)nae.onEffect;
							ok = naed(nae.spell,this,this.AttackTarget,nae.number);
						}
						if(nae.onEffect is NextAttackEffectDelegateMultiple)
						{
							ArrayList all = new ArrayList();
							NextAttackEffectDelegateMultiple naed = (NextAttackEffectDelegateMultiple)nae.onEffect;
							ok = naed(nae.spell,this,this.AttackTarget,all, nae.number);
						}
						if(ok)
							arr1.Add(nae);
						else nae.number++;
					}
					foreach(NextAttackEffect nae in arr1)
						this.NextAttackEffects.Remove(nae);
					arr1.Clear();
				}
				FaitFace( AttackTarget );
				int amountBlocked = 0;
				int amountAbsorbed = 0;
				int degats = Hit( AttackTarget, ref amountBlocked, ref amountAbsorbed );
				int offset = 4;
				if ( degats <= 0 )
					Converter.ToBytes( 0x1, tempBuff, ref offset );
				else
				{
					if ( this.Items[ (int)Slots.OffHand ] == null ||
						this.Items[ (int)Slots.OffHand ].IsShield ||
						Utility.Random( 2 ) == 0 )
						Converter.ToBytes( 0xE2, tempBuff, ref offset );
					else
						Converter.ToBytes( 0x2E2, tempBuff, ref offset );
				}
	
				Converter.ToBytes( Guid, tempBuff, ref offset );
				Converter.ToBytes( AttackTarget.Guid, tempBuff, ref offset );
				if ( degats < 0 )
					Converter.ToBytes( 0, tempBuff, ref offset );
				else
					Converter.ToBytes( degats, tempBuff, ref offset );
				Converter.ToBytes( (byte)1, tempBuff, ref offset );
				Converter.ToBytes( 0, tempBuff, ref offset );
				if ( degats > 0 )
					Converter.ToBytes( (float)degats/*DamageType*/, tempBuff, ref offset );
				else
					Converter.ToBytes( 0, tempBuff, ref offset );

				//		Converter.ToBytes( 0/*DamageType*/, tempBuff, ref offset );
				//		float ang = (float)Math.Atan2( AttackTarget.Y - Y, AttackTarget.X - X );
				if ( degats < 0 )
					Converter.ToBytes( 0, tempBuff, ref offset );
				else
					Converter.ToBytes( degats, tempBuff, ref offset );
				//	Converter.ToBytes( amountAbsorbed, tempBuff, ref offset );// damage absorbed 
				//	Converter.ToBytes( 0, tempBuff, ref offset ); // new victim state
				Converter.ToBytes( 0, tempBuff, ref offset ); // additional spell damage id
				Converter.ToBytes( 0, tempBuff, ref offset ); // additional spell damage id
				#region Degats types
				if ( degats >= 0 )
					Converter.ToBytes( 1, tempBuff, ref offset );
				else
					if ( degats == -1 )
					Converter.ToBytes( 2, tempBuff, ref offset );// dodge
				else
					if ( degats == - 2 )
					Converter.ToBytes( 9, tempBuff, ref offset );// parry
				else
					if ( degats == - 3 )
					Converter.ToBytes( 4, tempBuff, ref offset );// interrupted
				else
					if ( degats == - 4 || amountBlocked > 0 )
					Converter.ToBytes( 5, tempBuff, ref offset );// block
				else
					if ( degats == - 5 )
					Converter.ToBytes( 6, tempBuff, ref offset );// evade
				else
					if ( degats == - 6 )
					Converter.ToBytes( 7, tempBuff, ref offset );// immune
				else
					if ( degats == - 7 )
					Converter.ToBytes( 8, tempBuff, ref offset );// deflect

				#endregion
		
				if ( degats == 0 )
					Converter.ToBytes( 0xffffffff, tempBuff, ref offset );
				else
					Converter.ToBytes( 0, tempBuff, ref offset );
				Converter.ToBytes( 0, tempBuff, ref offset );
				Converter.ToBytes( 0, tempBuff, ref offset );
				ToAllPlayerNear( OpCodes.SMSG_ATTACKERSTATEUPDATE, tempBuff, offset );					

				AttackTarget.LooseHits( this, degats, true );
			}
			else
				account.ToAllPlayerNear( OpCodes.SMSG_ATTACKSWING_NOTINRANGE, tooFar, 4 );

			if ( AttackTarget.Dead )
			{
				int off = 4;
				Converter.ToBytes( Guid, tempBuff, ref off );
				Converter.ToBytes( AttackTarget.Guid, tempBuff, ref off );
				account.ToAllPlayerNear( OpCodes.SMSG_ATTACKSTOP, tempBuff, off );
				StopAttacking();
				AttackTarget = null;
			}
		}
示例#5
0
		public void OnFirstHit()
		{
			if ( AttackTarget == null )
			{
				StopAttacking();
				return;
			}
//#if DEBUG
			//Console.WriteLine("Reputation {0}/{1}", this.Reputation( AttackTarget ) );
//#endif
			if ( AttackTarget is BaseCreature )
				AttackTarget.UpdateXYZ();
			if ( Mobile.GetDirection( this as Mobile, AttackTarget ) != Pos.Front )
			{
				account.ToAllPlayerNear( OpCodes.SMSG_ATTACKSWING_BADFACING, tempBuff, 4 );
				return;
			}
			float dist = Distance( AttackTarget );
			if ( dist < 11 * ( AttackTarget.CombatReach + CombatReach ) )
			{				
				lastDistance = dist;
				if ( firstHitCombatTimer != null )
					firstHitCombatTimer.Stop();
				firstHitCombatTimer = null;
				FaitFace( AttackTarget );
				int amountAbsorbed = 0;
				int amountBlocked = 0;
				Hit( AttackTarget, ref amountAbsorbed, ref amountBlocked );
				//Hit( AttackTarget );
				combatTimer = new CombatTimer( AttackTarget.Guid, this, activeWeapon.Delay / 3 );
			}
			else
			{
				compteur++;
				if ( compteur % 10 == 1 )
				{
				/*	SendMessage( "" + X.ToString() + ", " + Y.ToString() + ", " + Z.ToString() + " / " +
						AttackTarget.X.ToString() + ", " + AttackTarget.Y.ToString() + ", " + AttackTarget.Z.ToString() + " dist = " + Distance( AttackTarget ).ToString() );*/
					account.ToAllPlayerNear( OpCodes.SMSG_ATTACKSWING_NOTINRANGE, tooFar, 4 );
				}
			}

		}
示例#6
0
		public void StopAttacking()
		{
			if ( firstHitCombatTimer != null )
			{
				firstHitCombatTimer.Stop();
				firstHitCombatTimer = null;
			}
			if ( combatTimer != null )
			{
				combatTimer.Stop();
				combatTimer = null;
			}
			if ( AttackTarget == null )
				return;
			int offset = 4;
			Converter.ToBytes( Guid, tempBuff, ref offset );
			Converter.ToBytes( AttackTarget.Guid, tempBuff, ref offset );
			Converter.ToBytes( 0, tempBuff, ref offset );
			account.ToAllPlayerNear( OpCodes.SMSG_ATTACKSTOP, tempBuff, offset );
			AttackTarget = null;
		}
    public ScenarioPlayScreen(Scenario selectedScenario)
    {
        //CommandIcon = ResourceManager.instance.GetIconTexture("Icon_CommandPoint");
        //MoneyIcon = ResourceManager.instance.GetIconTexture("Icon_Money");

        PlayerFleet  = new FleetData();
        EnemyFleet   = new FleetData();
        AlliedFleet  = new FleetData();
        NeutralFleet = new FleetData();

        PlayerShipManager  = new ShipManager(true, PlayerFleet, 9);
        EnemyShipManager   = new ShipManager(false, EnemyFleet, 10);
        AlliedShipManager  = new ShipManager(false, AlliedFleet, 11);
        NeutralShipManager = new ShipManager(false, NeutralFleet, 13);

        ShipManagers.Add(PlayerShipManager);
        ShipManagers.Add(EnemyShipManager);
        ShipManagers.Add(AlliedShipManager);
        ShipManagers.Add(NeutralShipManager);

        PlayerShipManager.SetPause(true);
        EnemyShipManager.SetPause(true);
        AlliedShipManager.SetPause(true);
        NeutralShipManager.SetPause(true);
        EnemyShipManager.SetAI(true);
        AlliedShipManager.SetAI(true);

        //Set Combat diplomacy
        PlayerShipManager.AddEnemyShipManager(EnemyShipManager);
        PlayerShipManager.AddAlliedShipManager(AlliedShipManager);
        EnemyShipManager.AddEnemyShipManager(PlayerShipManager);
        EnemyShipManager.AddEnemyShipManager(AlliedShipManager);
        AlliedShipManager.AddEnemyShipManager(EnemyShipManager);
        AlliedShipManager.AddAlliedShipManager(PlayerShipManager);

        shipDragSelectionBox = new ShipDragSelectionBox();

        float toolTipWidth = Screen.width * 0.175f;

        ToolTip = new GUIToolTip(new Vector2(Screen.width - toolTipWidth, 0), toolTipWidth);

        float MiniMapSize = Screen.height * 0.2f;
        Rect  miniMapRect = new Rect(Screen.width - Screen.height * 0.215f, Screen.height - Screen.height * 0.215f, MiniMapSize, MiniMapSize);

        miniMap = new MiniMap(miniMapRect, GameManager.instance.miniMapTexture, ToolTip);
        float GameSpeedButtonSize = miniMapRect.width / 5f;

        gameSpeedButton = new GameSpeedButton(new Rect(miniMapRect.x - GameSpeedButtonSize, miniMapRect.yMax - GameSpeedButtonSize, GameSpeedButtonSize, GameSpeedButtonSize), ToolTip);

        Vector2 shipPanelSize = new Vector2(Screen.width * 0.5f, Screen.height * 0.25f);

        shipInfoPanel = new ShipCombatInfoPanel(this, new Rect(new Vector2((Screen.width - shipPanelSize.x) / 2, Screen.height - shipPanelSize.y), shipPanelSize), PlayerShipManager, ToolTip);

        SetupPanel = new Rect(0, 0, Screen.width * 0.25f, Screen.height * 0.6f);

        Rect battleTimerRect = new Rect(Screen.width * 0.475f, 0, Screen.width * 0.05f, Screen.height * 0.03f);

        combatTimer = new CombatTimer(battleTimerRect, ToolTip);

        shipHullList = new ShipHullScrollList(new Rect(SetupPanel.width * 0.1f, SetupPanel.height * 0.01f, SetupPanel.width * 0.8f, SetupPanel.height * 0.375f), ChangeHull, CheckHullValid);

        DesignScrollWindowRect = new Rect(shipHullList.getRect().x, shipHullList.getRect().yMax + SetupPanel.height * 0.01f, shipHullList.getRect().width, shipHullList.getRect().height);
        DesignScrollViewRect   = new Rect(0, 0, DesignScrollWindowRect.width * 0.92f, DesignScrollWindowRect.height * 1.02f);
        DesignScrollPostion    = Vector2.zero;

        CommandRect     = new Rect((SetupPanel.width - GameManager.instance.StandardLabelSize.x) / 2f, DesignScrollWindowRect.yMax + SetupPanel.height * 0.01f, GameManager.instance.StandardLabelSize.x, GameManager.instance.StandardLabelSize.y);
        MoneyRect       = new Rect(CommandRect.x, CommandRect.yMax + SetupPanel.height * 0.01f, GameManager.instance.StandardLabelSize.x, GameManager.instance.StandardLabelSize.y);
        StartButtonRect = new Rect((SetupPanel.width - GameManager.instance.StandardButtonSize.x * 2) / 4f, MoneyRect.yMax + SetupPanel.height * 0.01f, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);
        BackButtonRect  = new Rect((SetupPanel.width / 2f) + (SetupPanel.width - GameManager.instance.StandardButtonSize.x * 2) / 4f, StartButtonRect.y, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);

        //Summary
        SummaryScrollList = new CombatSummaryScrollList();

        //Pause
        Vector2 pauseButtonSize = new Vector2(Screen.width * 0.078125f, Screen.height * 0.037037f);

        ContinueButtonRect = new Rect((Screen.width - pauseButtonSize.x) / 2f, Screen.height / 3.5f, pauseButtonSize.x, pauseButtonSize.y);
        QuitButtonRect     = new Rect(ContinueButtonRect.x, ContinueButtonRect.yMax, pauseButtonSize.x, pauseButtonSize.y);

        shipHullList.CheckFirstHull(ChangeHull);

        LoadScenario(selectedScenario);
    }
示例#8
0
文件: Mobile.cs 项目: karliky/wowwow
		public void MeleeCombatSlice()
		{
			Running = true;
			if (AttackTarget != null && AttackTarget.ImmuneAttack)
			{
				if ( combatTimer != null )
					combatTimer.Stop();
				combatTimer = null;
				this.lastAttack = AttackStatus.Immune;
				return;
			}
			if ( AttackTarget == null )
			{
				if ( combatTimer != null )
					combatTimer.Stop();
				combatTimer = null;
				return;
			}
			if ( AttackTarget.HitPoints > 0 && HitPoints > 0 )
			{
				UpdateXYZ();
				if ( !( AttackTarget is Character ) )
					AttackTarget.UpdateXYZ();
				float dist = Distance( AttackTarget );
				//	Console.WriteLine("target {0},{1},{2} dist = {3}", AttackTarget.X, AttackTarget.Y, AttackTarget.Z, dist );
				//	Console.WriteLine("from   {0},{1},{2} dist = {3}", X, Y, Z, dist );
				if ( dist > combatReach && dist < 8 * ( combatReach + AttackTarget.CombatReach ) )
				{
					if(this.AttackTarget != null)
						{
										
							ArrayList NAEbuff = (ArrayList)NextAttackEffects.Clone();
							foreach(NextAttackEffect nae in NAEbuff)
							{
						
								this.OnSpellTemplateResults(nae.spell,this.AttackTarget);
								this.NextAttackSpellGo(nae);
						
							}
					
							NAEbuff.Clear();
						}

					//FaitFace( target );
					int amountAbsorbed = 0;
					int amountBlocked = 0;
					int degats = Hit( AttackTarget, ref amountAbsorbed, ref amountBlocked );

					AIState = AIStates.Fighting;
					MoveTo( (float)( X + ( AttackTarget.X - X ) * 0.02f ), (float)( Y + ( AttackTarget.Y - Y ) * 0.02f ), (float)( AttackTarget.Z ) );

					int offset = 4;
					if ( degats <= 0 )
						Converter.ToBytes( 0x22, tempBuff, ref offset );
					else
						Converter.ToBytes( 0x22, tempBuff, ref offset );
	
					Converter.ToBytes( Guid, tempBuff, ref offset );
					Converter.ToBytes( AttackTarget.Guid, tempBuff, ref offset );
					if ( degats < 0 )
						Converter.ToBytes( 0, tempBuff, ref offset );
					else
						Converter.ToBytes( degats, tempBuff, ref offset );
					Converter.ToBytes( (byte)1, tempBuff, ref offset );
					Converter.ToBytes( 0, tempBuff, ref offset );
					if ( degats > 0 )
						Converter.ToBytes( (float)degats/*DamageType*/, tempBuff, ref offset );
					else
						Converter.ToBytes( 0, tempBuff, ref offset );

			//		Converter.ToBytes( 0/*DamageType*/, tempBuff, ref offset );
					//		float ang = (float)Math.Atan2( AttackTarget.Y - Y, AttackTarget.X - X );
					if ( degats < 0 )
						Converter.ToBytes( 0, tempBuff, ref offset );
					else
						Converter.ToBytes( degats, tempBuff, ref offset );
				//	Converter.ToBytes( amountAbsorbed, tempBuff, ref offset );// damage absorbed 
				//	Converter.ToBytes( 0, tempBuff, ref offset ); // new victim state
					Converter.ToBytes( 0, tempBuff, ref offset ); // additional spell damage id
					Converter.ToBytes( 0, tempBuff, ref offset ); // additional spell damage id
					#region Degats types
					if ( degats >= 0 )
						Converter.ToBytes( 1, tempBuff, ref offset );
					else
					if ( degats == -1 )
						Converter.ToBytes( 2, tempBuff, ref offset );// dodge
					else
						if ( degats == - 2 )
						Converter.ToBytes( 9, tempBuff, ref offset );// parry
					else
						if ( degats == - 3 )
						Converter.ToBytes( 4, tempBuff, ref offset );// interrupted
					else
						if ( degats == - 4 || amountBlocked > 0 )
						Converter.ToBytes( 5, tempBuff, ref offset );// block
					else
						if ( degats == - 5 )
						Converter.ToBytes( 6, tempBuff, ref offset );// evade
					else
						if ( degats == - 6 )
						Converter.ToBytes( 7, tempBuff, ref offset );// immune
					else
						if ( degats == - 7 )
						Converter.ToBytes( 8, tempBuff, ref offset );// deflect

					#endregion
		
					if ( degats == 0 )
						Converter.ToBytes( 0xffffffff, tempBuff, ref offset );
					else
					Converter.ToBytes( 0, tempBuff, ref offset );
					Converter.ToBytes( 0, tempBuff, ref offset );
					Converter.ToBytes( 0, tempBuff, ref offset );
					//HexViewer.View( tempBuff, 0, offset );
					ToAllPlayerNear( OpCodes.SMSG_ATTACKERSTATEUPDATE, tempBuff, offset );					

					AttackTarget.LooseHits( this, degats, true );

					if ( AttackTarget.Dead )
					{
						int off = 4;
						Converter.ToBytes( Guid, tempBuff, ref off );
						Converter.ToBytes( AttackTarget.Guid, tempBuff, ref off );
						ToAllPlayerNear( OpCodes.SMSG_ATTACKSTOP, tempBuff, off );						
						if ( combatTimer != null )
							combatTimer.Stop();
						AttackTarget = null;
					}					
					
				}
				else
				{
					float less = 1.0f;
					if ( dist > 20 )
						less = 0.5f;
					double angle = (float)Math.Atan2( AttackTarget.Y - Y, AttackTarget.X - X );
					angle += Math.PI;
					MoveTo( (float)( AttackTarget.X + Math.Cos( angle ) * ( combatReach + AttackTarget.CombatReach ) * 1.5 * less ), (float)( AttackTarget.Y + Math.Sin( angle ) * ( combatReach + AttackTarget.CombatReach ) * 1.5 * less ), (float)( AttackTarget.Z ) );
					AIState = AIStates.Attack;
				}
			}
			if ( ( this as BaseCreature ).IsStillActive() )
				ChooseAttackMode();
		}
示例#9
0
文件: Mobile.cs 项目: karliky/wowwow
		public void ChooseAttackMode()
		{
			if ( this.ForceFlee )
				return;
			if ( this.ForceStun )
				return;
			if ( Dead || AttackTarget == null || AttackTarget.HitPoints <= 0 )
			{
				AttackTarget = null;
				AIState = AIStates.DoingNothing;
				if ( combatTimer != null )
				{
					combatTimer.Stop();
					combatTimer = null;
				}
				return;
			}
			/*
			if ( this.knownAbilities.Count > 0 )//	spell caster
			{				
				SpellsTypes choosed = SpellsTypes.None;
				int spellChoosed = 0;

				#region Choice
				IDictionaryEnumerator Enumerator = knownAbilities.GetEnumerator();
				while (Enumerator.MoveNext())
				{
					cast.baseability = null;
					cast.castingtime = 0;
					cast.cool = 0;
					cast.id = 0;
					cast.manacost = 0;
					cast.type = 0;
					cast.duration =0;
					cast.radius =0;

					int spell = (int)Enumerator.Key;
					SpellsTypes type = (SpellsTypes)Enumerator.Value;
					#region cast creation
				{
					BaseAbility ba;
					
					ba = (BaseAbility)Abilities.abilities[spell];
					
					if (ba is SpellTemplate)
					{
						
						SpellTemplate st;
						
						st = (SpellTemplate)ba;
						
						this.cast.castingtime = st.CastingTime(this);
						this.cast.cool = st.CoolDown(this);
						this.cast.id = st.Id;
						this.cast.manacost = st.GetManaCost(this);
						this.cast.type = (ushort)type;
						this.cast.baseability = st;
						int radius = st.Radius1;
						if(st.Radius2 > radius) radius = st.Radius2;
						if(st.Radius3 > radius) radius = st.Radius3;
						if(ba is AuraEffect)
							this.cast.duration = (ba as AuraEffect).Duration(this);
						else cast.duration = 0;
						this.cast.radius = (short)radius;
						
					}
					else
					{
						
						this.cast.castingtime = ba.CastingTime(this);
						this.cast.cool = ba.CoolDown(this);
						this.cast.id = ba.Id;
						this.cast.manacost = 0;
						this.cast.type = (ushort)type;
						this.cast.baseability = ba;
						this.cast.radius =0;
						this.cast.duration =0;
						
					}
				}
					#endregion

					if ( type == SpellsTypes.Healing && this.HitPoints < this.BaseHitPoints / 2 )
					{
						if ( cast.baseability is SpellTemplate )
						{
							SpellTemplate st = (SpellTemplate)cast.baseability;
							if ( cast.manacost <= Mana )
							{
								choosed = type;
								spellChoosed = spell;
								
								break;
							
							}
						}
					}
					else
						if ( type == SpellsTypes.Curse )
					{
					}
					else
						if ( type == SpellsTypes.Defensive )
					{
						BaseAbility ba = Abilities.abilities[ spell ];
						if ( ba is AuraEffect )
						{
							AuraEffect ae = (AuraEffect)ba;
							bool alreadyCasted = false;
							foreach( AuraReleaseTimer art in aura )
								if ( art.ae == ae )
								{
									alreadyCasted = true;
									break;
								}
							if ( !alreadyCasted && cast.manacost <= Mana )
							{								
								
								choosed = type;
								spellChoosed = spell;
								break;
							
							}
						}
					}
					else
						if ( type == SpellsTypes.Offensive && AttackTarget != null && !AttackTarget.Dead )
					{
						BaseAbility ba = Abilities.abilities[ spell ];
						if ( ba is SpellTemplate )
						{
							SpellTemplate st = (SpellTemplate)ba;
							if ( cast.manacost <= Mana )
							{
								if ( spellChoosed == 0 )
								{
									choosed = type;
									spellChoosed = spell;
									break;
									
								}
							}
						}
					}
				}
				#endregion

				#region Apply decision
				if ( spellChoosed != 0 )
				{
					if (cast.baseability is SpellTemplate)
					{
						SpellTemplate st = (SpellTemplate)Abilities.abilities[ spellChoosed ];
						switch( choosed )
						{
							case SpellsTypes.Healing:
								beingCasting = st;
								if ( SpellTemplate.SpellEffects[ cast.id ] is SingleTargetSpellEffect )
									SingleTargetCastSpell( this, cast.id, 0x8000 );
								else
									if ( SpellTemplate.SpellEffects[ cast.id] is OnSelfSpellEffect )
								{									
									CastOnSelf( false, cast.id, 0 );
								}
								else
									FakeCast( cast.id, AttackTarget, new WhenDone( this.SpellTakeEffect ) );
								beingCasting = null;
								spellChoosed = 0;
								break;
							case SpellsTypes.Defensive:
								beingCasting = st;
								if ( SpellTemplate.SpellEffects[ cast.id ] is SingleTargetSpellEffect )
									SingleTargetCastSpell( this, cast.id, 0x8000 );
								else
									if ( SpellTemplate.SpellEffects[ cast.id ] is OnSelfSpellEffect )
								{									
									CastOnSelf( false, cast.id, 0 );
								}
								beingCasting = null;
								spellChoosed = 0;
								break;
							case SpellsTypes.Offensive:
								if ( AttackTarget == null )
									break;
								MoveTo( (float)( X + ( AttackTarget.X - X ) * 0.02f ), (float)( Y + ( AttackTarget.Y - Y ) * 0.02f ), (float)( AttackTarget.Z ) );
								beingCasting = st;
								if ( SpellTemplate.SpellEffects[ cast.id ] is SingleTargetSpellEffect )
									SingleTargetCastSpell( AttackTarget, cast.id, 2 );//0x8000 );
								else
									if ( SpellTemplate.SpellEffects[ cast.id ] is OnSelfSpellEffect )
								{									
									CastOnSelf( false, cast.id, 0 );
								}
								else
									FakeCast( cast.id, AttackTarget, new WhenDone( this.SpellTakeEffect ) );
								beingCasting = null;
								spellChoosed = 0;
								break;
						}
					}
				}
				#endregion
			}*/
			attackMode = 0;//	melee
			combatTimer = new CombatTimer( this, this.AttackSpeed );
			
			//	MeleeCombatSlice();
		}
    public MainCustomBattleScreen()
    {
        quitResumeSubScreen = new QuitResumeSubScreen(this, CloseScreen);

        ShipSelectionRect = new Rect(0, 0, Screen.width * 0.25f, Screen.height * 0.65f);

        ShipsCategoryButtonRect    = new Rect(ShipSelectionRect.x + ShipSelectionRect.width * 0.02f, ShipSelectionRect.y, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);
        StationCategoryButtonRect  = new Rect(ShipSelectionRect.x + (ShipSelectionRect.width - GameManager.instance.StandardButtonSize.x) / 2f, ShipSelectionRect.y, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);
        FightersCategoryButtonRect = new Rect(ShipSelectionRect.xMax - (GameManager.instance.StandardButtonSize.x + ShipSelectionRect.width * 0.02f), ShipSelectionRect.y, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);

        Rect UnitListRect = new Rect(ShipSelectionRect.width * 0.05f, ShipsCategoryButtonRect.yMax + ShipSelectionRect.height * 0.01f, ShipSelectionRect.width * .9f, ShipSelectionRect.height * 0.25f);

        shipHullList    = new ShipHullScrollList(UnitListRect, ChangeHull, CheckHullValid);
        stationHullList = new StationHullScrollList(UnitListRect, ChangeStationHull, CheckStationHullValid);
        fighterList     = new FighterScrollList(new Rect(UnitListRect.x, UnitListRect.y, UnitListRect.width, UnitListRect.height * 2f), ChangeFighter, CheckFighterValid);

        DesignScrollWindowRect = new Rect(shipHullList.getRect().x, shipHullList.getRect().yMax + Screen.height * 0.025f, shipHullList.getRect().width, shipHullList.getRect().height);
        DesignScrollViewRect   = new Rect(0, 0, DesignScrollWindowRect.width * 0.92f, DesignScrollWindowRect.height + 1);
        DesignScrollPostion    = Vector2.zero;

        OwnerPlayerButtonRect  = new Rect(ShipSelectionRect.width / 2 - GameManager.instance.StandardButtonSize.x / 2, DesignScrollWindowRect.yMax + GameManager.instance.StandardButtonSize.y, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);
        OwnerEnemyButtonRect   = new Rect(OwnerPlayerButtonRect.x, OwnerPlayerButtonRect.yMax, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);
        OwnerAlliedButtonRect  = new Rect(OwnerPlayerButtonRect.x, OwnerEnemyButtonRect.yMax, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);
        OwnerNeutralButtonRect = new Rect(OwnerPlayerButtonRect.x, OwnerAlliedButtonRect.yMax, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);

        float indent = (ShipSelectionRect.width - GameManager.instance.StandardButtonSize.x * 2f) / 3f;

        StartButtonRect   = new Rect(indent, ShipSelectionRect.yMax - GameManager.instance.StandardButtonSize.y * 2, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);
        SummaryButtonRect = new Rect(StartButtonRect.xMax + indent, StartButtonRect.y, GameManager.instance.StandardButtonSize.x, GameManager.instance.StandardButtonSize.y);

        PlayerFleet  = new FleetData();
        EnemyFleet   = new FleetData();
        AlliedFleet  = new FleetData();
        NeutralFleet = new FleetData();

        PlayerShipManager  = new ShipManager(true, PlayerFleet, 9);
        EnemyShipManager   = new ShipManager(false, EnemyFleet, 10);
        AlliedShipManager  = new ShipManager(false, AlliedFleet, 11);
        NeutralShipManager = new ShipManager(false, NeutralFleet, 13);

        ShipManagers.Add(PlayerShipManager);
        ShipManagers.Add(EnemyShipManager);
        ShipManagers.Add(AlliedShipManager);
        ShipManagers.Add(NeutralShipManager);

        SetPauseShipManagers(true);

        EnemyShipManager.SetAI(true);
        AlliedShipManager.SetAI(true);

        //Set Combat diplomacy
        PlayerShipManager.AddEnemyShipManager(EnemyShipManager);
        PlayerShipManager.AddAlliedShipManager(AlliedShipManager);
        EnemyShipManager.AddEnemyShipManager(PlayerShipManager);
        EnemyShipManager.AddEnemyShipManager(AlliedShipManager);
        AlliedShipManager.AddEnemyShipManager(EnemyShipManager);
        AlliedShipManager.AddAlliedShipManager(PlayerShipManager);

        shipDragSelectionBox = new ShipDragSelectionBox();

        float toolTipWidth = Screen.width * 0.175f;

        ToolTip = new GUIToolTip(new Vector2(Screen.width - toolTipWidth, 0), toolTipWidth);

        Vector2 shipPanelSize = new Vector2(Screen.width * 0.5f, Screen.height * 0.25f);

        shipInfoPanel = new ShipCombatInfoPanel(this, new Rect(new Vector2((Screen.width - shipPanelSize.x) / 2, Screen.height - shipPanelSize.y), shipPanelSize), PlayerShipManager, ToolTip);

        float MiniMapSize = Screen.height * 0.2f;
        Rect  miniMapRect = new Rect(Screen.width - Screen.height * 0.215f, Screen.height - Screen.height * 0.215f, MiniMapSize, MiniMapSize);

        miniMap = new MiniMap(miniMapRect, GameManager.instance.miniMapTexture, ToolTip);
        float GameSpeedButtonSize = miniMapRect.width / 5f;

        gameSpeedButton = new GameSpeedButton(new Rect(miniMapRect.x - GameSpeedButtonSize, miniMapRect.yMax - GameSpeedButtonSize, GameSpeedButtonSize, GameSpeedButtonSize), ToolTip);

        combatTimer = new CombatTimer(new Rect(Screen.width * 0.475f, 0, Screen.width * 0.05f, Screen.height * 0.03f), ToolTip);

        Rect fleetCombatInfoPanelRect = new Rect(0, Screen.height - shipPanelSize.y, shipPanelSize.y, shipPanelSize.y);

        fleetCombatInfoPanel = new FleetCombatInfoPanel(fleetCombatInfoPanelRect, PlayerFleet, GameManager.instance);

        shipHullList.CheckFirstHull(ChangeHull);

        doubleClickDetector = new DoubleClickDetector(0.25f);
        combatCameraMover   = new CombatCameraMover();
        storedUnitPanel     = new CombatStoredUnitPanel(PlayerShipManager, ToolTip);

        SummaryScrollList = new CombatSummaryScrollList();

        ContructDesignDisplayWindow();
    }
示例#11
0
 void InitializeComboLogic()
 {
     _attackComboTimerComponent = GetComponentInChildren <CombatTimer>();
     _attackComboTimerComponent.gameObject.SetActive(false);
     _attackCurrentComboTimer = _attackInitialComboTimer;
 }