public BattleUnitActionCenter(BattleUnit user) { mActionOwner = user; IdleAction = BattleUnitActionFactory.Instance.Allocate(ActionTypeDef.ActionTypeIdle) as ActionIdle; IdleAction.Owner = mActionOwner; IdleAction.Start(new ActionIdleInitParam()); }
public BlueDemon(GameWorld world, Vector2 position) : base(world, position) { AI = new AIEnemyHuman(this); Weapon = new WeaponFireSword(20, new Vector2(10, 40)); CurrentAction = new ActionIdle(this); InitHealth(80); }
public Player(IUser user, string name) { currentAction = new ActionIdle(this); this.user = user; this.name = name; inventory = new PlayerInventory(this); preferences["pm"] = (Preference <bool>)true; preferences["mention"] = (Preference <bool>)true; }
//public override bool Attacking => CurrentAction is ActionAttack; public MoaiMan(GameWorld world, Vector2 position) : base(world, position) { //Weapon = new WeaponWandOrange(10, 16, new Vector2(8, 32)); //Weapon = new WeaponUnarmed(10, 14, new Vector2(7, 28)); AI = new AIEnemyHuman(this); Weapon = Weapon.PresetWeaponList[Random.Next(0, Weapon.PresetWeaponList.Length - 1)]; //Weapon = new WeaponKatana(15, new Vector2(10, 40)); //Weapon = new WeaponRapier(15, new Vector2(10, 40)); //Weapon = new WeaponAlchemicalGauntlet(10, new Vector2(6, 4)); CurrentAction = new ActionIdle(this); InitHealth(80); }
private void AddActionIdle(MessageType msgType) { try { ActionIdle actionIdle = new ActionIdle(); actionIdle.OutMesssage = new UserControl.Message(msgType, "$DCT_LOGIN"); stack.ResetActionStack(actionIdle); } catch (Exception ex) { DealExcepion(ex); } }
public object Idle(params object[] objs) { bool sendMessage = Convert.ToBoolean(objs[0]); bool bRet = (bool)TryFinishAction(); if (bRet) { ActionIdle idle = new ActionIdle(Owner); idle.IsPushStack = sendMessage; Owner.DispatchEvent(ControllerCommand.SetActiveAction, idle); } return(null); }
public FighterStateMachine( Fighter fighter, float runSpeed ) : base() { Character.Anim.FighterAnimation fighterAnimation = fighter.GetComponent <Character.Anim.FighterAnimation> (); Character.Anim.MoveableAnimation moveableAnimation = fighter.GetComponent <Character.Anim.MoveableAnimation> (); CharacterController characterController = fighter.GetComponent <CharacterController> (); mActionIdle = new ActionIdle((int)eCharacterState.idle, moveableAnimation); mActionAttack = new ActionAttack((int)eCharacterState.attack, fighter); mActionRun = new ActionRun((int)eCharacterState.run, moveableAnimation, fighter.transform, characterController, runSpeed); mActionDie = new ActionDie((int)eCharacterState.die, fighterAnimation); addAction(mActionIdle); addAction(mActionAttack); addAction(mActionRun); addAction(mActionDie); startNewAction((int)eCharacterState.idle, false); }
void Update() { if (Owner.BlackBoard.Health <= 0) { if (!isDeath) { StartCoroutine(PlayTeleport()); isDeath = true; } return; } else { Owner.CharacterController.SimpleMove(Vector3.zero); } // 只有当在警觉状态下,才会进行警戒计时 if (Alert() && Owner.Status == E_CurrentStatus.E_Idle) { alertStartTime += Time.deltaTime; ActionRotate actionRotate = ActionFactory.Create(ActionFactory.E_Type.E_Rotate) as ActionRotate; actionRotate.Direction = targetDir; animComponent.HandleAction(actionRotate); Owner.BlackBoard.WeaponState = E_WeaponState.Ready; } else { ActionIdle actionIdle = ActionFactory.Create(ActionFactory.E_Type.E_IDLE) as ActionIdle; animComponent.HandleAction(actionIdle); alertStartTime = 0; Owner.BlackBoard.WeaponState = E_WeaponState.NotInHands; } // 当超过警觉时间,切换为移动状态 if (alertStartTime > alertTime) { Owner.Status = E_CurrentStatus.E_Move; alertStartTime = 0; } if (Owner.Status == E_CurrentStatus.E_Move) { // 当进入移动状态时,判断敌人是否在视野范围内,如果是追击敌人,如果不在,返回到Idl状态,接着之前的行为 if (InView()) { ActionGoTo actionGoto = ActionFactory.Create(ActionFactory.E_Type.E_GOTO) as ActionGoTo; Owner.BlackBoard.MoveDir = targetDir.normalized; // 更新移动方向 Owner.BlackBoard.WeaponState = E_WeaponState.Ready; actionGoto.FinalPosition = targetPos; actionGoto.MoveType = E_MoveType.Forward; actionGoto.Motion = E_MotionType.Sprint; animComponent.HandleAction(actionGoto); } else { Owner.Status = E_CurrentStatus.E_Idle; Owner.BlackBoard.WeaponState = E_WeaponState.NotInHands; } } // 只要在攻击距离内,就直接切换到攻击状态 if (InAttackView() && Owner.Status == E_CurrentStatus.E_Move) { ActionAttack actionAttack = ActionFactory.Create(ActionFactory.E_Type.E_ATTACK) as ActionAttack; actionAttack.Target = Player.Instance.Agent; actionAttack.AttackDir = Player.Instance.transform.position - transform.position; animComponent.HandleAction(actionAttack); Owner.WorldState.SetWSProperty(E_PropKey.E_IDLING, false); Owner.Status = E_CurrentStatus.E_Attack; } if (Owner.Status == E_CurrentStatus.E_Attack && Owner.WorldState.GetWSProperty(E_PropKey.E_IDLING).GetBool()) { // Owner.Status = E_CurrentStatus.E_Idle; Owner.Status = E_CurrentStatus.E_Injury; } // 如果在受伤或者格挡状态,隔0.3s回Idle if (Owner.Status == E_CurrentStatus.E_Injury || Owner.Status == E_CurrentStatus.E_Block) { injuryStartTime += Time.deltaTime; } if (injuryStartTime > injuryTime) { Owner.Status = E_CurrentStatus.E_Idle; injuryStartTime = 0; } }
// 生成动作 static public ActionBase Create(E_Type type) { int index = (int)type; ActionBase a; if (m_UnusedActions[index].Count > 0) { a = m_UnusedActions[index].Dequeue(); } else { switch (type) { case E_Type.E_IDLE: a = new ActionIdle(); break; case E_Type.E_MOVE: a = new ActionMove(); break; case E_Type.E_GOTO: a = new ActionGoTo(); break; case E_Type.E_COMBAT_MOVE: a = new ActionCombatMove(); break; case E_Type.E_ATTACK: a = new ActionAttack(); break; case E_Type.E_ATTACK_ROLL: a = new ActionAttackRoll(); break; case E_Type.E_ATTACK_WHIRL: a = new ActionAttackWhirl(); break; case E_Type.E_INJURY: a = new ActionInjury(); break; case E_Type.E_DAMAGE_BLOCKED: a = new ActionDamageBlocked(); break; case E_Type.E_BLOCK: a = new ActionBlock(); break; case E_Type.E_ROLL: a = new ActionRoll(); break; case E_Type.E_INCOMMING_ATTACK: a = new ActionIncommingAttack(); break; case E_Type.E_WEAPON_SHOW: a = new ActionWeaponShow(); break; case E_Type.E_Rotate: a = new ActionRotate(); break; case E_Type.E_USE_LEVER: a = new ActionUseLever(); break; case E_Type.E_PLAY_ANIM: a = new ActionPlayAnim(); break; case E_Type.E_PLAY_IDLE_ANIM: a = new ActionPlayIdleAnim(); break; case E_Type.E_DEATH: a = new ActionDeath(); break; case E_Type.E_KNOCKDOWN: a = new ActionKnockdown(); break; case E_Type.E_Teleport: a = new ActionTeleport(); break; default: Debug.LogError("no Action to create"); return(null); } } a.Reset(); a.SetActive(); m_ActionsInAction.Add(a); return(a); }
public override void DoUpdate() { if (pause) { return; } if (Owner.property.heroObjType == KHeroObjectType.hotPlayer && null != Owner.AnimCmp && null != Owner.Weapon) { if (Owner.ActiveAction != null && Owner.ActiveAction.WeaponPosition != WeaponComponent.BIND_POINT.DEFAULT) { Owner.Weapon.SetWeaponPosition(Owner.ActiveAction.WeaponPosition); } else if (Owner.AnimCmp.IsFighting()) { Owner.Weapon.SetWeaponPosition(WeaponComponent.BIND_POINT.RIGHT_HAND); } else { Owner.Weapon.SetWeaponPosition(WeaponComponent.BIND_POINT.BEI); } } if (Owner.property.isDeadTemp) { if (null == Owner.ActiveAction || (Owner.ActiveAction.isDead == false && Owner.ActiveAction.actionType != Action.ACTION_TYPE.FLY)) { ActionDead dead = new ActionDead(Owner); Owner.ActiveAction = dead; } } if (Owner.ActiveAction.IsFinish()) { if (null == Owner.property.nextAction || !Owner.property.nextAction.IsCanActive()) { if (Owner.property.isMainHero) { if (null != Owner.property.target && Owner.property.target.property.isCanAttack && Owner.property.AutoAttack && !Owner.property.target.property.isDeadTemp && !Owner.property.CmdAutoAttack) { OperaAttack action = new OperaAttack(Owner); action.IsPushStack = true; KActiveSkill skill = KConfigFileManager.GetInstance().GetActiveSkill((uint)Owner.Job, 1); if (null == skill) { return; } action.deltaSpace = ((float)skill.CastRange) / 100f; action.target = Owner.property.target; Owner.ActiveAction = action; } else { if (OperaWalking) { if (Owner.Position.x != Owner.property.finalDestination.x || Owner.Position.z != Owner.property.finalDestination.z) { ActionWalk action = new ActionWalk(Owner); action.endPosition = Owner.property.finalDestination; Owner.ActiveAction = action; Owner.property.finalDestination = action.endPosition; } else { OperaWalking = false; ActionIdle action = new ActionIdle(Owner); Owner.ActiveAction = action; } } else { ActionIdle action = new ActionIdle(Owner); Owner.ActiveAction = action; } } } else { if (Owner.Position.x != Owner.property.finalDestination.x || Owner.Position.z != Owner.property.finalDestination.z) { ActionWalk action = new ActionWalk(Owner); action.beginPosition = Owner.Position; action.endPosition = Owner.property.finalDestination; action.speed = Owner.Speed; Owner.ActiveAction = action; Owner.property.finalDestination = action.endPosition; } else { ActionIdle action = new ActionIdle(Owner); Owner.ActiveAction = action; } } } else { Owner.ActiveAction = Owner.property.nextAction; Owner.property.nextAction = null; } } else { if (Owner.ActiveAction.actionType != Action.ACTION_TYPE.OPERA && !Owner.property.isMainHero) { if ( Mathf.Abs(Owner.Position.x - Owner.property.finalDestination.x) > 0.001f || Mathf.Abs(Owner.Position.z - Owner.property.finalDestination.z) > 0.001f ) { Owner.ActiveAction.TryFinish(); } } Owner.ActiveAction.Update(); } if (null != Owner.AidAction && !Owner.AidAction.IsFinish()) { Owner.AidAction.Update(); } }
public static void Create(string roleId) { EditorApplication.isPlaying = true; GameObject root = GameObject.Find("test scene"); if (null != root) { GameObject.DestroyImmediate(root); } root = new GameObject(); root.name = "test scene"; GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube); cube.name = "ground"; cube.isStatic = true; cube.transform.localScale = new Vector3(10f, 1f, 10f); cube.transform.parent = root.transform; cube.transform.localPosition = new Vector3(0, -1, 0); cube.layer = 8; GlobalCamp _GlobalCamp = root.AddComponent <GlobalCamp>(); _GlobalCamp.ground = 1 << cube.layer; LCHRoleData data = SkillEditorData.Instance.skillsData.GetRole(roleId); #if UNITY_EDITOR GameObject role = GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>(data.mod)); role.name = "Player"; role.transform.parent = root.transform; role.transform.localPosition = Vector3.zero; LCharacter c = role.AddComponent <LCharacter>(); c.camp = 0; c.animCtrl = role.GetComponent <Animation>(); SimpleVirtualInput vi = role.AddComponent <SimpleVirtualInput>(); ActionIdle idle = role.AddComponent <ActionIdle>(); ActionWalk walk = role.AddComponent <ActionWalk>(); ActionFall fail = role.AddComponent <ActionFall>(); { int cc = c.animCtrl.GetClipCount(); foreach (AnimationState states in c.animCtrl) { string name = states.name; if (name.IndexOf("idle", System.StringComparison.OrdinalIgnoreCase) >= 0) { idle.animName = name; } if (name.IndexOf("walk", System.StringComparison.OrdinalIgnoreCase) >= 0) { walk.animName = name; } if (name.IndexOf("run", System.StringComparison.OrdinalIgnoreCase) >= 0) { walk.animName = name; } if (name.IndexOf("down", System.StringComparison.OrdinalIgnoreCase) >= 0) { fail.animName = name; } if (name.IndexOf("fail", System.StringComparison.OrdinalIgnoreCase) >= 0) { fail.animName = name; } if (name.IndexOf("walk", System.StringComparison.OrdinalIgnoreCase) >= 0) { walk.animName = name; } } } #endif //GameObject role = }