void OnEnable() { if (!target) { Debug.LogWarning("Target is null"); return; } skillSetting = target as SkillSetting; }
public bool IsTimeOver() { SkillSetting skillSetting = SkillSetting.SkillSettingDict[SkillId]; if (PutSkillTime + skillSetting.SkillAttackTime <= Time.time) { return(true); } return(false); }
public SkillSetting clone() { SkillSetting n = new SkillSetting(); n.cd = cd; n.actDuration = actDuration; n.freezenTime = freezenTime; n.attackDuration = attackDuration; n.range = range; n.damage = damage; n.targetForce = targetForce; return n; }
public static void Init() { SkillSetting skill101 = new SkillSetting(101, "attack101", true, false, false, 1.5f, 1.5f, 1.0f, 0.5f, true); SkillSettingDict[101] = skill101; SkillSetting skill102 = new SkillSetting(102, "attack102", true, true, false, 0.0f, 0.0f, 1.0f, 0.7f, false); SkillSettingDict[102] = skill102; SkillSetting skill103 = new SkillSetting(103, "attack103", false, false, true, 0.0f, 0.0f, 1.0f, 0.3f, true); SkillSettingDict[103] = skill103; }
public void Open() { EntitySetting.Init(); BattleLoop.Instance.Init(); EntityMgr.Instance.Init(); SkillSetting.Init(); ViewMgr.Instance.Open(ViewNames.Main); LoadScenePrefab(); EntityMgr.Instance.CreateMainPlayer(); EntityMgr.Instance.CreateMonster(2); EntityMgr.Instance.CreateMonster(3); EntityMgr.Instance.CreateMonster(4); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { if (!skillSetting) { skillSetting = property.serializedObject.targetObject as SkillSetting; } skeletonAnimation = skillSetting.skeletonAnimation; if (!skeletonAnimation) { skillSetting.skeletonAnimation = skillSetting.gameObject.GetComponentInChildren <Spine.Unity.SkeletonAnimation>(); skeletonAnimation = skillSetting.skeletonAnimation; } if (!skeletonAnimation) { skillSetting.skeletonAnimation = skillSetting.gameObject.GetComponentInParent <Spine.Unity.SkeletonAnimation>(); skeletonAnimation = skillSetting.skeletonAnimation; } SerializedProperty listProperty = property.FindPropertyRelative("skillEventList"); /*ReorderableList*/ list = GetList(listProperty); float height = 0f; for (int i = 0; i < listProperty.arraySize; i++) { height = Mathf.Max(height, EditorGUI.GetPropertyHeight(listProperty.GetArrayElementAtIndex(i))) + 1.5f; } //애니메이션 지정 안되있으면 이벤트 목록 그리지 않음 //if (skeletonAnimation) { list.elementHeight = EditorGUIUtility.singleLineHeight * 3 + 20f; //list.DoList(position); list.DoLayoutList(); } }
public override void Hurt(SkillSetting setting, Character source) { base.Hurt(setting, source); if (!invincible) { CatWolfAI _ai = (CatWolfAI)ai; _ai.alerted = false; } }
public static bool ParseSkillSetting( #if USE_XML XmlNode _node , #endif // USE_XML ref string _SkillName , ref SkillSetting _SkillSetting ) { #if USE_XML bool ret = XMLParseLevelUtility.ParseSkillSetting( _node , ref _SkillName , ref _SkillSetting ) ; return ret ; #endif // USE_XML }
public static bool ParseSkillSetting( XmlNode _node , ref string _SkillLabel , ref SkillSetting _SkillSetting ) { if( "SkillSetting" == _node.Name ) { if( null != _node.Attributes[ "Label" ] ) { _SkillLabel = _node.Attributes[ "Label" ].Value ; _SkillSetting.Label = _node.Attributes[ "Label" ].Value ; } if( null != _node.Attributes[ "Type" ] ) { _SkillSetting.Type = _node.Attributes[ "Type" ].Value ; } if( null != _node.Attributes[ "Target" ] ) { _SkillSetting.Target = _node.Attributes[ "Target" ].Value ; } if( null != _node.Attributes[ "DefenseProperty" ] ) { _SkillSetting.DefenseProperty.Parse( _node.Attributes[ "DefenseProperty" ].Value ) ; Debug.Log( "ParseSkillSetting() , DefenseProperty=" + _SkillSetting.DefenseProperty.CreatePropertyString() ) ; } if( null != _node.Attributes[ "AttactProperty" ] ) { _SkillSetting.AttackProperty.Parse( _node.Attributes[ "AttactProperty" ].Value ) ; Debug.Log( "ParseSkillSetting() , AttackProperty=" + _SkillSetting.AttackProperty.CreatePropertyString() ) ; } if( null != _node.Attributes[ "FyingSpeed" ] ) { _SkillSetting.FyingSpeed = _node.Attributes[ "FyingSpeed" ].Value ; } if( null != _node.Attributes[ "AnimationPrefab" ] ) { _SkillSetting.AnimationPrefab = _node.Attributes[ "AnimationPrefab" ].Value ; } if( null != _node.Attributes[ "DisplayString" ] ) { _SkillSetting.DisplayString = _node.Attributes[ "DisplayString" ].Value ; } return true ; } return false ; }
public PlayerSet() { hp = 100f; stamina = 100f; staminaRecoverSpeed = 10f; dashCost = 20f; blockCost = 15f; dodgeCost = 20f; magic = 100f; magicRecoverSpeed = 0.3f; magicHitRecover = 3f; souls = 0; SkillSetting normalAttack1 = new SkillSetting(); normalAttack1.actDuration = SkillSetting.frameToSeconds(14, 30); normalAttack1.damage = 1f; normalAttack1.range = 1.4f; normalAttack1.attackDuration = 0.1f; normalAttack1.freezenTime = 0.15f; normalAttack1.targetForce = new Vector2(50, 0); normalAttack1.name = "normalAttack"; normalAttack.Add(normalAttack1); SkillSetting normalAttack2 = new SkillSetting(); normalAttack2.actDuration = SkillSetting.frameToSeconds(13, 30); normalAttack2.damage = 1f; normalAttack2.range = 1.4f; normalAttack2.attackDuration = 0.1f; normalAttack2.freezenTime = 0.1f; normalAttack2.targetForce = new Vector2(50, 0); normalAttack2.name = "normalAttack"; normalAttack.Add(normalAttack2); SkillSetting normalAttack3 = new SkillSetting(); normalAttack3.actDuration = SkillSetting.frameToSeconds(20, 30); normalAttack3.damage = 1f; normalAttack3.range = 1.4f; normalAttack3.attackDuration = 0.1f; normalAttack3.freezenTime = 0.2f; normalAttack3.targetForce = new Vector2(150, 0); normalAttack3.name = "normalAttack"; normalAttack.Add(normalAttack3); normalAttackBurn.damage = 1.5f; normalAttackBurn.duration = 2f; normalAttackBurn.maxOverlay = 1; block.actDuration = float.PositiveInfinity; dodge.actDuration = 0.45f; dodge.damage = 0f; dodge.range = 2f; overheadSwing.actDuration = SkillSetting.frameToSeconds(40, 30); overheadSwing.damage = 4f; overheadSwing.range = 1.5f; overheadSwing.cd = 1.3f; overheadSwing.freezenTime = 1f; overheadSwing.targetForce = new Vector2(200, 0); overheadSwing.name = "overheadSwing"; dropAttack.actDuration = 0.7f; dropAttack.damage = 2f; dropAttack.range = 1f; dropAttack.attackDuration = 0f; dropAttack.freezenTime = 0.5f; dropAttack.name = "dropAttack"; eruptionFireTimes = 2; eruptionFire.actDuration = 0.67f; eruptionFire.damage = 2f; eruptionFire.range = 1f; eruptionFire.attackDuration = 0.55f; eruptionFire.freezenTime = 0.6f; eruptionFireCost = 30f; eruptionFireBurn.damage = 2f; eruptionFireBurn.duration = 2f; eruptionFireBurn.maxOverlay = 1; }
public void DoCommand(BattleCommand command) { int entityId = command.EntityId; if (command.CommandType == BattleCommandType.Move) { EntitySetting setting = EntitySetting.Setting[entityId]; GameEntity gameEntity = EntityMgr.Instance.GetGameEntity(entityId); MoveComp moveComp = gameEntity.GetComponent(GameComponentsLookup.MoveComp) as MoveComp; moveComp.DestPos = command.MoveInfo.DestPos; moveComp.IsArrived = false; moveComp.Speed = setting.MoveSpeed; moveComp.IsAniMove = false; moveComp.Forward = Vector3.Normalize(moveComp.DestPos - moveComp.CurPos); BattleCommand command1 = new BattleCommand(); command1.CommandType = BattleCommandType.PlayAni; command1.EntityId = entityId; command1.PlayAniInfo = new BattleCommand.CommandPlayAniInfo(); command1.PlayAniInfo.AniName = "walk"; BattleLoop.Instance.AddCommand(command1); } else if (command.CommandType == BattleCommandType.PutSkill) { SkillSetting setting = SkillSetting.SkillSettingDict[command.PutSkillInfo.SkillId]; GameEntity gameEntity = EntityMgr.Instance.GetGameEntity(entityId); MoveComp moveComp = gameEntity.GetComponent(GameComponentsLookup.MoveComp) as MoveComp; PutedSkillInfo skillInfo = new PutedSkillInfo(); skillInfo.EntityId = entityId; skillInfo.PutSkillTime = Time.time; skillInfo.SkillId = command.PutSkillInfo.SkillId; moveComp.Speed = 0.1f; moveComp.IsAniMove = false; moveComp.IsBlock = false; if (setting.IsBlockWalk == true) { moveComp.DestPos = moveComp.CurPos; moveComp.IsArrived = true; } if (setting.IsNeedAniMove == true) { moveComp.Speed = 0.5f; moveComp.IsArrived = false; moveComp.IsAniMove = true; moveComp.DestPos = moveComp.CurPos + moveComp.Forward * 3.0f; } if (setting.IsBulletShoot == true) { moveComp.IsBlock = true; Timer.Instance.AddTimer(BattleTimerName.BulletMove, () => { Contexts contexts = EntityMgr.Instance.GetContexts(); HashSet <GameEntity> gameEntities = contexts.game.GetEntitiesWithEntityInfoCompEntityType(EntityType.Monster); int monsterId = 1; float dist = 10000.0f; foreach (var item in gameEntities) { float diff = (item.moveComp.CurPos - gameEntity.moveComp.CurPos).sqrMagnitude; if (diff < dist) { dist = diff; monsterId = item.entityInfoComp.Id; } } if (monsterId != 1) { GameEntity bullet = EntityMgr.Instance.CreateBullet(); bullet.entityBulletMoveComp.CurPos = gameEntity.moveComp.CurPos + new Vector3(0, 2.0f, 0); bullet.entityBulletMoveComp.DestEntityId = monsterId; mPutedSkillInfos.Insert(0, skillInfo); } moveComp.IsBlock = false; if (gameEntity.moveComp.IsArrived == false) { BattleCommand command2 = new BattleCommand(); command2.CommandType = BattleCommandType.PlayAni; command2.EntityId = entityId; command2.PlayAniInfo = new BattleCommand.CommandPlayAniInfo(); command2.PlayAniInfo.AniName = "walk"; BattleLoop.Instance.AddCommand(command2); } }, 0.6f, false); } else { mPutedSkillInfos.Insert(0, skillInfo); } BattleCommand command1 = new BattleCommand(); command1.CommandType = BattleCommandType.PlayAni; command1.EntityId = entityId; command1.PlayAniInfo = new BattleCommand.CommandPlayAniInfo(); command1.PlayAniInfo.AniName = setting.AniName; BattleLoop.Instance.AddCommand(command1); } else if (command.CommandType == BattleCommandType.PlayAni) { if (command.PlayAniInfo.AniName.Equals("attacked") == true) { GameEntity gameEntity = EntityMgr.Instance.GetGameEntity(entityId); gameEntity.moveComp.IsArrived = true; Timer.Instance.AddTimer(BattleTimerName.AttackedTimer, () => { if (gameEntity.hasEntityAiComp == true) { gameEntity.entityAiComp.IsAIEnded = true; } }, 1.0f, false); } BattleRenderCommand renderCommand = new BattleRenderCommand(); renderCommand.EntityId = entityId; renderCommand.AniName = command.PlayAniInfo.AniName; BattleRenderMgr.Instance.AddCommand(renderCommand); } }
public override void Hurt(SkillSetting setting, Character source) { base.Hurt(setting, source); if (!invincible && !blocked) slashing = false; }
public void Execute() { List <BattleCommandRuner.PutedSkillInfo> removeList = new List <BattleCommandRuner.PutedSkillInfo>(); List <BattleCommandRuner.PutedSkillInfo> putedSkillInfos = BattleCommandRuner.Instance.GetPutedSkillInfos(); Contexts contexts = EntityMgr.Instance.GetContexts(); for (int i = 0; i < putedSkillInfos.Count; i++) { SkillSetting skillSetting = SkillSetting.SkillSettingDict[putedSkillInfos[i].SkillId]; if (putedSkillInfos[i].PutSkillTime + skillSetting.SkillAttackTime <= Time.time) { HashSet <GameEntity> gameEntities = null; GameEntity entity = EntityMgr.Instance.GetGameEntity(putedSkillInfos[i].EntityId); if (entity.entityInfoComp.EntityType == EntityType.MainPlayer) { gameEntities = contexts.game.GetEntitiesWithEntityInfoCompEntityType(EntityType.Monster); } else { gameEntities = contexts.game.GetEntitiesWithEntityInfoCompEntityType(EntityType.MainPlayer); } foreach (var item in gameEntities) { Vector3 forward = entity.moveComp.Forward; Vector3 entityPos = item.moveComp.CurPos; Vector3 skillPutEntityPos = entity.moveComp.CurPos; //Debug.LogError(" 释放者 " + skillPutEntityPos.x + " " + skillPutEntityPos.z); //Debug.LogError(" 被攻击者 " + entityPos.x + " " + entityPos.z); //Debug.LogError(" forward " + forward.x + " " + forward.z); bool isAttacked = false; if (skillSetting.IsAttackForward == true) { if (Mathf.Abs(entityPos.x - skillPutEntityPos.x) <= skillSetting.AttackInfoCo.x && Mathf.Abs(entityPos.z - skillPutEntityPos.z) <= skillSetting.AttackInfoCo.y) { Vector3 vec1 = new Vector3(entityPos.x - skillPutEntityPos.x, entityPos.y - skillPutEntityPos.y, entityPos.z - skillPutEntityPos.z); vec1 = Vector3.Normalize(vec1); forward = Vector3.Normalize(forward); float cos = Vector3.Dot(vec1, forward); isAttacked = true; } } else { Vector3 diff = entityPos - skillPutEntityPos; if (diff.sqrMagnitude <= skillSetting.AttackInfoCo.r) { isAttacked = true; } } if (isAttacked == true) { BattleCommand command1 = new BattleCommand(); command1.CommandType = BattleCommandType.PlayAni; command1.EntityId = item.entityInfoComp.Id; command1.PlayAniInfo = new BattleCommand.CommandPlayAniInfo(); command1.PlayAniInfo.AniName = "attacked"; BattleLoop.Instance.AddCommand(command1); } } removeList.Insert(0, putedSkillInfos[i]); } } for (int i = 0; i < removeList.Count; i++) { BattleCommandRuner.Instance.RemovePutedSkillInfo(removeList[i]); } }
public override void Hurt(SkillSetting setting, Character source) { base.Hurt(setting, source); if (!invincible && !blocked) { normalAttackPhase = 0; normalAttacking = false; nextNormalAttack = false; } }
public void useSkill(string name, SkillSetting setting, bool canMove = false, bool enforce = false) { if (!skills.ContainsKey(name) || name == null) return; if (skillCooler[name] <= 0 && (canActing() || enforce)) { Debug.Log(name); if (enforce && currentSkill != null) cancelCurrentSkill(); actingTime = setting.actDuration + 0.05f; currentSkill = StartCoroutine(skills[name]()); skillCooler[name] = setting.cd; if (!canMove) { movementFreezenTime = setting.actDuration; } } }
public void useSkill(string name, SkillSetting setting, float antiStaggerTime, bool canMove = false, bool enforce = false) { useSkill(name, setting, canMove, enforce); this.antiStaggerTime = antiStaggerTime; }
public void useSkill(string name, SkillSetting setting, skillFunction interruptCallBack, bool canMove = false, bool enforce = false) { useSkill(name, setting, canMove, enforce); this.interruptCallBack = interruptCallBack; }
public virtual void Hurt(SkillSetting setting, Character source) { if (!invincible && !blocked) { getDemage(setting.damage); if (antiStaggerTime <= 0) { freezenTime = Mathf.Max(setting.freezenTime, freezenTime); cancelCurrentSkill(); StartCoroutine(hurtFlash(hurtFlashColor)); if (anim) { anim.SetInteger("skill", 0); anim.SetBool("hurt", true); } } else { StartCoroutine(hurtFlash(new Color(1, 0.4f, 0.4f))); } lastHurt = setting; } // Deal attack force if (setting.targetForce != null && antiStaggerTime <= 0) { Vector2 f = setting.targetForce; if (source != null) { if (source.facingRight) f.x = Mathf.Abs(f.x); else f.x = -Mathf.Abs(f.x); } body.AddForce(f); } }
public virtual void getDemage(float amount) { if (!invincible) { hp -= amount; lastHurt = null; } }
public void LoadSkill( string _SkillTemplateFilepath ) { Dictionary<string,SkillSetting> skillSettingTable = GlobalSingleton.GetSkillSettingTable() ; Debug.Log( "LoadSkill() _SkillTemplateFilepath=" + _SkillTemplateFilepath ) ; if( 0 == _SkillTemplateFilepath.Length ) { // warning Debug.LogWarning( "LoadSkill() 0 == _SkillTemplateFilepath.Length" + _SkillTemplateFilepath ) ; return ; } TextAsset ta = Resources.Load<TextAsset>( _SkillTemplateFilepath ); if( null == ta ) { Debug.LogError( "LoadSkill() null == ta" ) ; return ; } #if USE_XML XmlDocument doc = new XmlDocument() ; doc.LoadXml( ta.text ) ; XmlNode root = doc.FirstChild ; if( null == root ) { Debug.LogError( "LoadSkill() : null == root" ) ; return ; } // string levelname = root.Attributes[ "name" ].Value ; if( false == root.HasChildNodes ) { Debug.Log( "LoadSkill() : false == root.HasChildNodes" ) ; return ; } #endif // USE_XML #if USE_XML for( int i = 0 ; i < root.ChildNodes.Count ; ++i ) { XmlNode unitNode = root.ChildNodes[ i ] ; #endif // USE_XML string skillTemplateName = ""; SkillSetting skillSetting = new SkillSetting() ; if( 0 == unitNode.Name.IndexOf( "#comment" ) ) { // comment } else if( true == ParseUtility.ParseSkillSetting( unitNode, ref skillTemplateName , ref skillSetting ) ) { if( false == skillSettingTable.ContainsKey( skillTemplateName ) ) { skillSettingTable.Add( skillTemplateName , skillSetting ) ; } else { skillSettingTable[ skillTemplateName ] = skillSetting ; } Debug.Log( "skillSettingTable.Add skillTemplateName=" + skillTemplateName) ; Debug.Log( "skillSettingTable.Count=" + skillSettingTable.Count ) ; } #if USE_XML } #endif // USE_XML }
public void setAttr(SkillSetting setting) { this.setting = setting; }
//################################################################################################################################ virtual public void Init(BattleUnit owner, SkillSetting skillSetting) { if (!owner) { Debug.Log(gameObject.name + " : not defined owner. "); isInitialized = true; enabled = false; return; } if (!skillSetting) { Debug.Log(gameObject.name + " : not defined skillsetting"); isInitialized = true; enabled = false; return; } this.owner = owner; //if (owner) coolTimeController = owner.coolTimeController; this.skillSetting = skillSetting; //if (skillSetting) skillData = GameDataManager.skillDataDic[skillSetting.skillID]; if (skillData == null) { Debug.Log(gameObject.name + " : Not found skill data. Invalid id. " + skillSetting.skillID); isInitialized = true; enabled = false; return; } //스킬 효과 등록 for (int i = 0; i < skillSetting.skillEventList.Count; i++) { SkillEvent skillEvent = skillSetting.skillEventList[i]; //해당 이벤트 이름으로 등록 안 되어 있으면 추가 if (!skillEffectDic.ContainsKey(skillEvent.eventName)) { List <ISkillEffect> list = new List <ISkillEffect>(); skillEffectDic.Add(skillEvent.eventName, list); } List <ISkillEffect> skillEventList = skillEffectDic[skillEvent.eventName]; //같은 이벤트 이름인 애들 전부 같은 리스트에 묶어서 등록 switch (skillSetting.skillEventList[i].eventType) { //case SkillEvent.SkillEventType.ExecuteSkill: // skillEventList.Add(new SkillEffectExecuteSkill(this, skillSetting.skillEventList[i])); // break; case SkillEvent.SkillEventType.FireProjectile: skillEventList.Add(new SkillEffectFireProjectile(this, skillSetting.skillEventList[i])); break; case SkillEvent.SkillEventType.ShowParticle: skillEventList.Add(new SkillEffectShowParticle(this, skillSetting.skillEventList[i])); break; case SkillEvent.SkillEventType.MeleeHit: skillEventList.Add(new SkillEffectMeleeHit(this, skillSetting.skillEventList[i])); break; case SkillEvent.SkillEventType.Summon: skillEventList.Add(new SkillEffectSummon(this, skillSetting.skillEventList[i])); break; } //스킬 발동 타입의 이벤트만 예외 처리. 같은 이벤트 이름으로 등록된 애들끼리 묶어서 초기화 List <SkillEvent> executeSkillEvents = skillSetting.skillEventList.FindAll(x => x.eventName == skillEvent.eventName && x.eventType == SkillEvent.SkillEventType.ExecuteSkill); if (executeSkillEvents != null) { skillEventList.Add(new SkillEffectExecuteSkill(this, executeSkillEvents)); } } if (skillData.moveSpeed != 0f) { HeroMoveBehaviorMoveTowards m = new HeroMoveBehaviorMoveTowards(); m.skill = this; m.owner = owner as BattleHero; m.castTarget = castTarget; moveBehavior = m; } isInitialized = true; }
public virtual void init(Character c, SkillSetting setting) { _owner = c; this.setting = setting; }