void AnimationChecker()
    {
        //LEGS
        if (RB2D.velocity.x != 0f || RB2D.velocity.y != 0f)
        {
            LegAnimator.SetBool("IsMoving", true);
        }
        else
        {
            LegAnimator.SetBool("IsMoving", false);
        }

        //Weapons
        if (WeaponsOnHand [WeaponIndex] != null)         //this will make the system know to make the weapon on hand layer dominate the other ones.
        {
            PlayerAnimator.SetLayerWeight(WeaponsOnHand [WeaponIndex].GetComponent <WeaponClass> ().AnimationLayerIndex, 1f);
            CurrentAttack = WeaponsOnHand [WeaponIndex].GetComponent <WeaponClass> ().AttackAnimation;
        }
        else         //this is to makes sure the weapon layers don't mess with the fists layer
        {
            for (int i = 1; i < WeaponPool.Length; i++)
            {
                PlayerAnimator.SetLayerWeight(i, 0f);
            }
        }
    }
Esempio n. 2
0
 private void ToggleRenderAnimationStates(bool state)
 {
     for (int c = 0; c < characters.Length; c++)
     {
         LegAnimator comp = characters[c].GetComponent(typeof(LegAnimator)) as LegAnimator;
         comp.renderAnimationStates = state;
     }
 }
    public void PlayMotionQueued(int id)
    {
        LegAnimator component = base.gameObject.GetComponent <LegAnimator>();

        if (component)
        {
            component.enabled = false;
        }
        this.m_RoleMotion.SetMotionQueued(id);
    }
Esempio n. 4
0
 private void ToggleDisableLocomotion(bool state)
 {
     disableLocomotion = state;
     for (int c = 0; c < clones.Count; c++)
     {
         LegAnimator legA = clones[c].GetComponent(typeof(LegAnimator)) as LegAnimator;
         legA.enabled = !state;
         HeadLookController head = clones[c].GetComponent(typeof(HeadLookController)) as HeadLookController;
         head.enabled = !state;
     }
 }
    public void PlayIdleMotion()
    {
        LegAnimator component = base.gameObject.GetComponent <LegAnimator>();

        if (component)
        {
            component.enabled = true;
        }
        base.animation.CrossFade("locomotion");
        this.m_bPlayNormalMotion = false;
        this.m_RoleMotion.m_Id   = 0;
    }
    public void UpdateInputOnMovePlatform()
    {
        LegAnimator component = base.gameObject.GetComponent <LegAnimator>();

        if (component)
        {
            this.m_DirectionVector = GameInput.GetDirKeyMoveVector();
            if (this.m_DirectionVector != Vector3.zero || this.MoveTarget != null)
            {
                this.PlayIdleMotion();
                return;
            }
            component.enabled = false;
            this.PlayMotion(601);
        }
    }
 //To check if it's moving or not
 void AnimationChecker()
 {
     LegAnimator.SetBool("IsMoving", true);
 }
    protected override void initialize()
    {
        this.m_PlayerMotor = (base.GetComponent(typeof(M_PlayerMotor)) as M_PlayerMotor);
        if (this.m_PlayerMotor == null)
        {
            Debug.Log("Motor is null!!");
        }
        this.m_JumpMotor = (base.GetComponent(typeof(JumpAndIdle)) as JumpAndIdle);
        Vector3 position = base.transform.position;

        if (!base.GetComponent <NavMeshAgent>())
        {
            this.m_NavMeshAgent = base.gameObject.AddComponent <NavMeshAgent>();
            this.m_NavMeshAgent.acceleration = 200f;
            this.m_NavMeshAgent.angularSpeed = 500f;
            this.m_NavMeshAgent.baseOffset   = -0.01f;
            this.m_NavMeshAgent.walkableMask = 1;
            this.m_NavMeshAgent.enabled      = false;
        }
        base.transform.position = position;
        this.m_RoleMotion       = base.GetComponent <M_GameRoleMotion>();
        if (this.m_RoleMotion != null)
        {
            this.m_RoleMotion.Init(base.RoleID, 601);
        }
        LegAnimator component = base.gameObject.GetComponent <LegAnimator>();

        if (component)
        {
            int num = 1024;
            num |= 4;
            num |= 16;
            num  = ~num;
            component.groundLayers = num;
        }
        LegController component2 = base.gameObject.GetComponent <LegController>();

        if (component2)
        {
            for (int i = 0; i < component2.sourceAnimations.Length; i++)
            {
                if (component2.sourceAnimations[i].name == "walk")
                {
                    this.m_WalkSpeed = component2.sourceAnimations[i].nativeSpeed;
                }
                if (component2.sourceAnimations[i].name == "run")
                {
                    this.m_RunSpeed = component2.sourceAnimations[i].nativeSpeed;
                }
                if (component2.sourceAnimations[i].name == "sprint")
                {
                    this.m_DashSpeed = component2.sourceAnimations[i].nativeSpeed;
                }
            }
        }
        base.gameObject.AddComponent <M_FootStep>();
        if (Swd6Application.instance.m_ExploreSystem.m_MapData.emType == ENUM_MapType.World)
        {
            this.m_RunSpeed = 3.6f;
        }
        this.targetPointObj = Swd6Application.instance.m_ExploreSystem.m_MoveTargetPoint;
        this.m_GuiManager   = Swd6Application.instance.guiManager;
        this.m_MoveTarget   = null;
        this.m_IsRun        = Swd6Application.instance.m_ExploreSystem.Run;
        this.m_PlayerMotor.maxForwardSpeed = this.m_RunSpeed;
        this.m_JumpHeight  = this.m_PlayerMotor.jumpHeight;
        this.m_JumpGravity = this.m_PlayerMotor.gravity;
        if (Swd6Application.instance.m_ExploreSystem.m_MapData.emType == ENUM_MapType.Town)
        {
            this.m_JumpHeight = 1.1f;
        }
        this.PlayFaceMotion(2);
        UI_Explore.Instance.SetDashState(false, this.m_IsRun);
        if (Swd6Application.instance.m_ResourceType == ENUM_ResourceType.Develop)
        {
            Debug.Log("Player Init OK!!");
        }
    }
Esempio n. 9
0
    private void UseCharacter(int nr)
    {
        activeCharacter = nr;

        // Switch relevant characters on and off
        for (int c = 0; c < characters.Length; c++)
        {
            if (c == nr)
            {
                characters[nr].SetActive(true);
            }
            else
            {
                characters[c].SetActive(false);
            }
        }

        // Apply new character to relevant controllers
        SmoothFollowCamera2 sf = cameraController.GetComponent(typeof(SmoothFollowCamera2)) as SmoothFollowCamera2;

        sf.target = characters[activeCharacter];
        if (showGhost)
        {
            sf.offset = Vector3.right * -characterBounds[activeCharacter].magnitude / 2;
        }
        else
        {
            sf.offset = Vector3.zero;
        }
        sf.distance  = characterBounds[activeCharacter].magnitude * (showGhost ? 1.8f : 1.2f);
        sc.character = characters[activeCharacter];

        // Apply position to character
        characters[activeCharacter].transform.position =
            characters[oldCharacter].transform.position
            + Vector3.up * (initHeights[activeCharacter] - initHeights[oldCharacter]);

        if (clones.Count > 0)
        {
            for (int c = 1; c < clones.Count; c++)
            {
                Destroy(clones[c]);
            }
        }
        clones.Clear();
        clones.Add(characters[activeCharacter]);

        if (ghost != null)
        {
            Destroy(ghost);
            ghost = null;
        }

        if (showGhost)
        {
            // Add ghost for character
            ghost = (GameObject)Instantiate(characters[activeCharacter]);

            // Remove all unneccasary components from ghost
            Component[] components;
            int         tries = 0;
            do
            {
                components = ghost.GetComponents(typeof(Component));
                foreach (Component component in components)
                {
                    Type type = component.GetType();
                    if (
                        type != typeof(Transform) &&
                        type != typeof(Animation) &&
                        (
                            (tries > 0) ||
                            (
                                type != typeof(LegController) &&
                                type != typeof(CharacterController) &&
                                type != typeof(AlignmentTracker)
                            )
                        )
                        )
                    {
                        Destroy(component);
                    }
                }
                tries++;
            } while (components.Length > 2 && tries < 2);

            // Add ghost scrip to ghost
            GhostOriginal ghostComponent = ghost.AddComponent(typeof(GhostOriginal)) as GhostOriginal;
            ghostComponent.character = characters[activeCharacter];
            ghostComponent.offset    = new Vector3(-characterBounds[activeCharacter].magnitude, 0, 0);

            LegAnimator LegA = characters[activeCharacter].GetComponent(typeof(LegAnimator)) as LegAnimator;
            LegA.ghost = ghost;
        }
    }
Esempio n. 10
0
    void CopySerialized(Transform src, Transform tar)
    {
        if (src == null || tar == null)
        {
            return;
        }

        Rigidbody rigid = src.GetComponent <Rigidbody>();

        if (rigid != null)
        {
            Rigidbody rigid1 = tar.GetComponent <Rigidbody>();
            if (rigid1 == null)
            {
                rigid1 = tar.gameObject.AddComponent <Rigidbody>();
            }

            EditorUtility.CopySerialized(rigid, rigid1);
        }

        CapsuleCollider cap1 = src.GetComponent <CapsuleCollider>();

        if (cap1 != null)
        {
            CapsuleCollider cap2 = tar.GetComponent <CapsuleCollider>();
            if (cap2 == null)
            {
                cap2 = tar.gameObject.AddComponent <CapsuleCollider>();
            }
            EditorUtility.CopySerialized(cap1, cap2);

            cap2.center *= scale;
            cap2.radius *= scale;
            cap2.height *= scale;
        }

        SphereCollider s1 = src.GetComponent <SphereCollider>();

        if (s1 != null)
        {
            SphereCollider s2 = tar.GetComponent <SphereCollider>();
            if (s2 == null)
            {
                s2 = tar.gameObject.AddComponent <SphereCollider>();
            }
            EditorUtility.CopySerialized(s1, s2);

            s2.center *= scale;
            s2.radius *= scale;
        }

        BoxCollider box1 = src.GetComponent <BoxCollider>();

        if (box1 != null)
        {
            BoxCollider box2 = tar.GetComponent <BoxCollider>();
            if (box2 == null)
            {
                box2 = tar.gameObject.AddComponent <BoxCollider>();
            }
            EditorUtility.CopySerialized(box1, box2);

            box2.center *= scale;
            box2.size   *= scale;
        }

        CharacterJoint joint1 = src.GetComponent <CharacterJoint>();

        if (joint1 != null)
        {
            CharacterJoint joint2 = tar.GetComponent <CharacterJoint>();
            if (joint2 == null)
            {
                joint2 = tar.gameObject.AddComponent <CharacterJoint>();
            }
            EditorUtility.CopySerialized(joint1, joint2);

            joint2.connectedBody = AiUtil.GetChild(target.transform, joint2.connectedBody.name).GetComponent <Rigidbody>();
        }

        LegController leg1 = src.GetComponent <LegController>();

        if (leg1 != null)
        {
            LegController leg2 = tar.GetComponent <LegController>();
            if (leg2 == null)
            {
                leg2 = tar.gameObject.AddComponent <LegController>();
            }
            EditorUtility.CopySerialized(leg1, leg2);

            leg2.groundedPose = target.GetComponent <Animation>()[leg2.groundedPose.name].clip;
            leg2.rootBone     = AiUtil.GetChild(target.transform, leg2.rootBone.name);

            foreach (LegInfo leg in leg2.legs)
            {
                leg.ankle = AiUtil.GetChild(target.transform, leg.ankle.name);
                leg.hip   = AiUtil.GetChild(target.transform, leg.hip.name);
                leg.toe   = AiUtil.GetChild(target.transform, leg.toe.name);

                leg.footLength   *= scale;
                leg.footWidth    *= scale;
                leg.footOffset.x *= scale;
                leg.footOffset.y *= scale;
            }

            foreach (MotionAnalyzer motion in leg2.sourceAnimations)
            {
                motion.animation = target.GetComponent <Animation>()[motion.animation.name].clip;
            }
        }

        AlignmentTracker al1 = src.GetComponent <AlignmentTracker>();

        if (leg1 != null)
        {
            AlignmentTracker al2 = tar.GetComponent <AlignmentTracker>();
            if (al2 == null)
            {
                al2 = tar.gameObject.AddComponent <AlignmentTracker>();
            }
            EditorUtility.CopySerialized(al1, al2);
        }

        LegAnimator legA1 = src.GetComponent <LegAnimator>();

        if (legA1 != null)
        {
            LegAnimator legA2 = tar.GetComponent <LegAnimator>();
            if (legA2 == null)
            {
                legA2 = tar.gameObject.AddComponent <LegAnimator>();
            }
            EditorUtility.CopySerialized(legA1, legA2);
        }
    }
Esempio n. 11
0
    protected virtual void ActivateRagdoll(bool active)
    {
        if (model == null)
        {
            return;
        }

        Collider _collider = GetComponent <Collider>();

        if (_collider != null)
        {
            if (active || m_isDead)
            {
                _collider.enabled = false;
            }
            else
            {
                _collider.enabled = true;
            }
        }

        Animator _animator = GetComponent <Animator>();

        if (_animator != null)
        {
            if (active || m_isDead)
            {
                _animator.enabled = false;
            }
            else
            {
                _animator.enabled = true;
            }
        }

        Animation _animation = model.GetComponent <Animation>();

        if (_animation != null)
        {
            if (active || m_isDead)
            {
                _animation.enabled = false;
            }
            else
            {
                _animation.enabled = true;
            }
        }

        ArmAimer aimer = GetComponent <ArmAimer>();

        if (aimer != null)
        {
            if (active || m_isDead)
            {
                aimer.enabled = false;
            }
            else
            {
                aimer.enabled = true;
            }
        }

        LegAnimator legAni = GetComponentInChildren <LegAnimator>();

        if (legAni != null && active)
        {
            legAni.enabled = false;
        }

        Rigidbody[] rigids = model.GetComponentsInChildren <Rigidbody>();
        foreach (Rigidbody rigid in rigids)
        {
            if (active)
            {
                rigid.WakeUp();
            }
            else
            {
                rigid.Sleep();
            }

            rigid.isKinematic = !active;

            //if (active)
            //{
            //    rigid.AddForce(transform.forward * 7500, ForceMode.Force);
            //}
        }

//        Collider[] colliders = model.GetComponentsInChildren<Collider>();
//        foreach (Collider c in colliders)
//        {
//            //c.enabled = active;
//        }
    }