Пример #1
0
        public object OnMoveToDestination(params object[] objs)
        {
            if (objs.Length < 1)
            {
                return(null);
            }

            Vector3 _destination;

            _destination = (Vector3)objs[0];

            bool sendMessage = false;

            if (objs.Length >= 2)
            {
                sendMessage = Convert.ToBoolean(objs[1]);
            }

            if (Owner.property.isMainHero)
            {
                Owner.property.finalDestination = KingSoftCommonFunction.GetGoundHeight(_destination);
                AnimationComponent.OperaWalking = true;
            }

            EventRet ret  = Owner.DispatchEvent(ControllerCommand.TryFinishAction);
            bool     bRet = (bool)ret.GetReturn <AnimationComponent>();

            if (bRet)
            {
                ActionWalk walk = new ActionWalk(Owner);
                if (objs.Length >= 3)
                {
                    walk.deltaSpace = (float)(objs[3]);
                }
                walk.speed       = Owner.Speed;
                walk.IsPushStack = sendMessage;
                walk.endPosition = _destination;
                Owner.DispatchEvent(ControllerCommand.SetActiveAction, walk);
            }
            else
            {
                Owner.DispatchEvent(ControllerCommand.ActionMoveToDistance, _destination, Owner.Speed, sendMessage);
            }

            return(null);
        }
Пример #2
0
 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();
     }
 }
Пример #3
0
        public object OnDestinationChange(params object[] objs)
        {
            Vector3 destination = (Vector3)objs[0];

            destination = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(destination));
            int moveType = (int)objs[1];

            Owner.property.destination = destination;
            if (!Owner.property.isMainHero)
            {
                Owner.property.finalDestination = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(destination));
            }
            if (Owner.Position == Owner.property.destination)
            {
                return(null);
            }
            if (moveType == (int)KForceMoveType.fmtJump)
            {
                Owner.DispatchEvent(ControllerCommand.Jump, destination);
                return(null);
            }
            else if (moveType == (int)KForceMoveType.fmtRush)
            {
                Owner.DispatchEvent(ControllerCommand.Drag, destination);
                return(null);
            }
            else if (moveType == (byte)KForceMoveType.fmtPull)
            {
                Owner.DispatchEvent(ControllerCommand.Drag, destination);
                return(null);
            }
            else if (moveType == (byte)KForceMoveType.fmtBack)
            {
                Owner.DispatchEvent(ControllerCommand.Back, destination);
                return(null);
            }
            else if (moveType == (byte)KForceMoveType.fmtPlayerFuKong)
            {
                Owner.DispatchEvent(ControllerCommand.FuKong, destination);
                return(null);
            }
            else //if (moveType == (byte)KForceMoveType.fmtInvalid)
            {
                bool bRet = Owner.ActiveAction.TryFinish();
                if (!bRet)
                {
                    bool bRet2 = Owner.ActiveAction.MoveToDistance(destination, Owner.Speed);
                    if (bRet2)
                    {
                        if (Owner.property.isMainHero)
                        {
                            Owner.property.finalDestination = KingSoftCommonFunction.GetGoundHeight(KingSoftCommonFunction.NearPosition(destination));
                        }
                        return(null);
                    }
                }
                if (Owner.Position.x == destination.x && Owner.Position.z == destination.z)
                {
                    Owner.Position = destination;
                    return(null);
                }
                ActionWalk walk = new ActionWalk(Owner);
                walk.speed       = Owner.Speed;
                walk.IsPushStack = false;
                walk.endPosition = destination;
                Owner.DispatchEvent(ControllerCommand.SetActiveAction, walk);
            }
            return(null);
        }
Пример #4
0
    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 =
    }