// Use this for initialization void Start() { Gamedata = FindObjectOfType <GameDataHolder>(); battleEvent = FindObjectOfType <BattleEventHandler>(); area = AreaType.area1; }
public Battle(BattleInfo info, SpriteFont font) { _BattleInfo = info; _BattleState = BattleStatus.Intro; _BattleHUD = new BattleHUD(this, font); //Initialize the Events. BattleStateChange += new BattleEventHandler(OnBattleStateChange); BattleStateChange(this); }
public override void ProcessAction() { //Bouge le curseur if (Input.GetKeyDown(KeyCode.DownArrow)) { if (indexSelection < validTargets.Count - 1) { choixMenu[indexSelection].color = couleurBase; mapInterface.SendMessage("DeselectMonster", indexSelection); ++indexSelection; choixMenu[indexSelection].color = couleurSelection; mapInterface.SendMessage("SelectMonster", indexSelection); } } else if (Input.GetKeyDown(KeyCode.UpArrow)) { if (indexSelection > 0) { choixMenu[indexSelection].color = couleurBase; mapInterface.SendMessage("DeselectMonster", indexSelection); --indexSelection; choixMenu[indexSelection].color = couleurSelection; mapInterface.SendMessage("SelectMonster", indexSelection); } } //Confirm le choix if (Input.GetKeyDown(KeyCode.Return)) { action.AddTarget(validTargets[indexSelection]); mapInterface.SendMessage("DeselectMonster", indexSelection); BattleEventHandler.AddPlayerAction(action); } //Cancel action if (Input.GetKeyDown(KeyCode.Escape)) { //Check if it was a skill or normal attack if (action.GetType() == typeof(UseSkill)) { BattleEventHandler.ChangeState(BattleEventHandler.ActionState.SKILL); } else if (action.GetType() == typeof(Attack)) { BattleEventHandler.ChangeState(BattleEventHandler.ActionState.ACTION); } } }
protected virtual void OnBattleStartEvent(BattleEventArgs e) { if (enemyDeckId != "" && e.Type == "day") { if (e.Data["api_formation"] != null) { enemyFormation = e.Data["api_formation"][1].ToString(); } } BattleEventHandler handler = BattleStart; if (handler != null) { handler(this, e); } }
private void ConfirmAction() { switch (indexSelection) { //Attaque case 0: BattleEventHandler.AttackEnnemyState(); break; //Skill case 1: BattleEventHandler.SelectSkillState(); break; //Item case 2: break; //Run case 3: break; } }
protected virtual void OnBattleFinishEvent(BattleEventArgs e) { if (enemyDeckId != "") { EnemyDeckInfo info = new EnemyDeckInfo(enemyDeckId, enemyFormation, e.Data["api_enemy_info"]["api_deck_name"].ToString(), e.Data["api_ship_id"]); EnemyDeckMap.Add(enemyDeckId, JToken.FromObject(info)); enemyDeckId = ""; enemyFormation = ""; List <string> lx = new List <string>(); foreach (JToken item in EnemyDeckMap.Values) { lx.Add(item.ToString()); } string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "data", defEnemyDeck); File.WriteAllText(path, string.Format("[{0}]", string.Join(",", lx))); } BattleEventHandler handler = BattleFinish; if (handler != null) { handler(this, e); } }
protected override void Run(ETModel.Session session, M2C_CreateUnits message) { UnitComponent unitComponent = ETModel.Game.Scene.GetComponent <UnitComponent>(); foreach (UnitInfo unitInfo in message.Units) { if (unitComponent.Get(unitInfo.UnitId) != null) { continue; } UnitData unitData = new UnitData(); unitData.groupIndex = (GroupIndex)unitInfo.GroupIndex; unitData.layerMask = (UnitLayerMask)unitInfo.LayerMask; unitData.unitLayer = (UnitLayer)unitInfo.UnitLayer; unitData.unitTag = (UnitTag)unitInfo.UnitTag; Unit unit = UnitFactory.Create(unitInfo.UnitId, 1001, unitData); NumericComponent numericComponent = unit.GetComponent <NumericComponent>(); foreach (var v in unitInfo.UnitNumerics) { numericComponent.Set((NumericType)v.Type, v.Value); } BattleEventHandler.LoadAssets(unit); Vector3 postion = new Vector3(unitInfo.Position.X, unitInfo.Position.Y, unitInfo.Position.Z); unit.GameObject.transform.forward = new Vector3(unitInfo.Dir.X, unitInfo.Dir.Y, unitInfo.Dir.Z); unit.Position = postion; Dictionary <Type, IProperty> unitStateList = new Dictionary <Type, IProperty>(); P_Position property_Position = new P_Position(); property_Position.Value = postion; // 防止掉下去 unitStateList.Add(typeof(P_Position), property_Position); unit.GetComponent <UnitStateComponent>().Init(unitStateList); } }
public void Awake() { otherPlayers = new List <Unit>(); Game.Scene.GetComponent <GlobalConfigComponent>().networkPlayMode = false; Game.EventSystem.Run(EventIdType.LoadAssets); { UnitData playerData = new UnitData(); playerData.groupIndex = GroupIndex.Player; playerData.layerMask = UnitLayerMask.ALL; playerData.unitLayer = UnitLayer.Character; playerData.unitTag = UnitTag.Player; //创建主角 Unit v = UnitFactory.Create(IdGenerater.GenerateId(), 1001, playerData); v.Position = new UnityEngine.Vector3(-10, 0, -10); UnitComponent.Instance.MyUnit = v; v.AddComponent <CameraComponent>(); v.AddComponent <CommandComponent>(); var input = v.AddComponent <InputComponent>(); var list = v.GetComponent <ActiveSkillComponent>().skillList.Keys.ToArray(); input.AddSkillToHotKey("Q", list[0]); input.AddSkillToHotKey("W", list[1]); input.AddSkillToHotKey("E", list[2]); BattleEventHandler.LoadAssets(v); } UnitData monsterData = new UnitData(); monsterData.groupIndex = GroupIndex.Monster; monsterData.layerMask = UnitLayerMask.ALL; monsterData.unitLayer = UnitLayer.Character; monsterData.unitTag = UnitTag.Monster; { //创建怪物 Unit v = UnitFactory.Create(IdGenerater.GenerateId(), 1001, monsterData); v.Position = new UnityEngine.Vector3(4.2f, 4, -15); v.Rotation = UnityEngine.Quaternion.LookRotation(v.Position - UnitComponent.Instance.MyUnit.Position, Vector3.up); //v.AddComponent<PDynamicBodyComponent, Shape>(new CircleShape() { Radius = 0.5f }); BattleEventHandler.LoadAssets(v); otherPlayers.Add(v); } { //创建怪物 Unit v = UnitFactory.Create(IdGenerater.GenerateId(), 1001, monsterData); v.Position = new UnityEngine.Vector3(-10, 0, 11); v.Rotation = UnityEngine.Quaternion.LookRotation(v.Position - UnitComponent.Instance.MyUnit.Position, Vector3.up); //v.AddComponent<PDynamicBodyComponent, Shape>(new CircleShape() { Radius = 0.5f }); BattleEventHandler.LoadAssets(v); otherPlayers.Add(v); } { //创建怪物 Unit v = UnitFactory.Create(IdGenerater.GenerateId(), 1001, monsterData); v.Position = new UnityEngine.Vector3(-10, 0, 15); v.Rotation = UnityEngine.Quaternion.LookRotation(v.Position - UnitComponent.Instance.MyUnit.Position, Vector3.up); //v.AddComponent<PDynamicBodyComponent, Shape>(new CircleShape() { Radius = 0.5f }); BattleEventHandler.LoadAssets(v); otherPlayers.Add(v); } //这里准备其他角色施放技能的参数 }
public override void ProcessAction() { //Bouge le curseur if (Input.GetKeyDown(KeyCode.DownArrow)) { if (indexSelection < curUnit.KnownSkills.Count - 2) { choixMenu[indexSelection].color = couleurBase; ++indexSelection; ++indexSelection; choixMenu[indexSelection].color = couleurSelection; } else if (indexSelection < curUnit.KnownSkills.Count - 1) { choixMenu[indexSelection].color = couleurBase; ++indexSelection; choixMenu[indexSelection].color = couleurSelection; } } else if (Input.GetKeyDown(KeyCode.UpArrow)) { if (indexSelection >= 2) { choixMenu[indexSelection].color = couleurBase; --indexSelection; --indexSelection; choixMenu[indexSelection].color = couleurSelection; } } else if (Input.GetKeyDown(KeyCode.RightArrow)) { if (indexSelection < curUnit.KnownSkills.Count - 2) { choixMenu[indexSelection].color = couleurBase; ++indexSelection; choixMenu[indexSelection].color = couleurSelection; } else if (indexSelection == curUnit.KnownSkills.Count - 2) { choixMenu[indexSelection].color = couleurBase; --indexSelection; choixMenu[indexSelection].color = couleurSelection; } } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { if (indexSelection > 0) { choixMenu[indexSelection].color = couleurBase; --indexSelection; choixMenu[indexSelection].color = couleurSelection; } } //Confirm le choix if (Input.GetKeyDown(KeyCode.Return)) { if (curUnit.curHp > curUnit.KnownSkills[indexSelection].hpCost && curUnit.curMana >= curUnit.KnownSkills[indexSelection].manaCost) { BattleEventHandler.UseSkillState(curUnit.KnownSkills[indexSelection]); } } //Cancel action if (Input.GetKeyDown(KeyCode.Escape)) { BattleEventHandler.ChangeState(BattleEventHandler.ActionState.ACTION); } }
public async Task RunAsync(BattleEventHandler <BattleContext> handler) { Console.WriteLine("Damaged"); }