Esempio n. 1
0
    void Awake()
    {
        m_Camera    = Camera.main;
        m_Ani       = GetComponent <Animator>();
        m_Rigidbody = GetComponent <Rigidbody>();
        m_AimSystem = GetComponent <AimSystem>();
        m_AimIK     = GetComponent <AimIK>();

        m_Weapons = new List <Weapon>();

        //Get transform of righthand
        rightHand = transform.GetChild(0).GetChild(0).GetChild(0).GetChild(0).GetChild(2).GetChild(0).GetChild(0).GetChild(0);

        //오른손의 자식으로 설정된 무기들을 m_Weapons에 추가하고, 비활성화 시킨다.
        for (int i = 0; i < rightHand.childCount; i++)
        {
            Weapon weap = rightHand.GetChild(i).GetComponent <Weapon>();
            weap.m_ShootTarget = m_AimSystem.m_RayTarget;
            m_Weapons.Add(weap);
            weap.gameObject.SetActive(false);
        }

        m_WeaponInhand = m_Weapons[0];
        m_WeaponInhand.gameObject.SetActive(true);
        m_AimIK.SetHandsIKPosition(m_WeaponInhand.m_GrabPosRight, m_WeaponInhand.m_GrabPosLeft);
    }
Esempio n. 2
0
 void Start()
 {
     Application.targetFrameRate = 60;
     animator = GetComponent <Animator>();
     rb       = GetComponent <Rigidbody>();
     iK       = GetComponent <AimIK>();
 }
Esempio n. 3
0
    private void AddAimIK()
    {
        if (aimIK == null)
        {
            if (animator != null)
            {
                aimIK = gameObject.AddComponent <AimIK>();
                aimIK.solver.poleAxis   = Vector3.right;
                aimIK.solver.poleWeight = 1;

                //aimIK.solver.AddBone(animator.GetBoneTransform(HumanBodyBones.RightShoulder));
                aimIK.solver.AddBone(animator.GetBoneTransform(HumanBodyBones.RightUpperArm));
                aimIK.solver.AddBone(animator.GetBoneTransform(HumanBodyBones.RightLowerArm));
                aimIK.solver.AddBone(animator.GetBoneTransform(HumanBodyBones.RightHand));

                if (aimIK.solver.bones.Length > 0)
                {
                    aimIK.solver.bones[0].weight = 0;
                }

                aimIKTarget             = new GameObject(name + " AimIKTarget");
                aimIK.solver.target     = aimIKTarget.transform;
                aimIKPole               = new GameObject(name + " AimIKPole");
                aimIK.solver.poleTarget = aimIKPole.transform;
            }
        }
    }
Esempio n. 4
0
 void Start()
 {
     animator = transform.GetComponent <Animator>();
     sas      = transform.GetComponent <SimpleAimingSystem>();
     aik      = transform.GetComponent <AimIK>();
     laik     = transform.GetComponent <LookAtIK>();
 }
Esempio n. 5
0
    void GetIKs(Transform root)
    {
        if (m_IKs == null && root != null)
        {
            m_IKs = new AimIK[0];

            Transform ikTrans = PEUtil.GetChild(root, "GrounderIK");
            if (ikTrans != null)
            {
                for (int i = 0; i < ikBones.Length; i++)
                {
                    Transform tr = PEUtil.GetChild(ikTrans, ikBones[i]);
                    if (tr != null)
                    {
                        AimIK ik = tr.GetComponent <AimIK>();
                        if (ik != null)
                        {
                            System.Array.Resize(ref m_IKs, m_IKs.Length + 1);
                            m_IKs[m_IKs.Length - 1] = ik;
                        }
                    }
                }
            }
        }
    }
Esempio n. 6
0
 void Awake()
 {
     m_animator            = GetComponent <Animator>();
     m_CapsuleCollider     = GetComponent <CapsuleCollider>();
     m_CharacterController = GetComponent <CharacterController>();
     m_AimIk = GetComponent <AimIK>();
 }
Esempio n. 7
0
 private void Awake()
 {
     anim     = GetComponent <Animator>();
     shootSys = GetComponent <EnemyShootAttackSystem>();
     meleeSys = GetComponent <EnemyMeleeSystem>();
     ik       = GetComponent <AimIK>();
 }
Esempio n. 8
0
    void Awake()
    {
        interactionSystem = GetComponent <InteractionSystem>();
        mAnim             = GetComponent <Animator>();

        recoil = GetComponent <Recoil>();
        mAimIK = GetComponent <AimIK>();
    }
Esempio n. 9
0
    // Use this for initialization
    void Awake()
    {
        m_Data       = GetComponent <PlayerData>();
        m_CameraMove = Camera.main.GetComponent <CameraMove>();
        m_AimIK      = GetComponent <AimIK>();
        m_Ani        = GetComponent <Animator>();

        m_Data.m_MaxHp = 100;
    }
Esempio n. 10
0
 private void Awake()
 {
     playerAnimation  = GetComponent <PlayerAnimation>();
     playerMovement   = GetComponent <PlayerMovement>();
     playerIK         = GetComponent <AimIK>();
     handIK           = GetComponent <FBIKBoxing>();
     spawnProjectiles = GetComponent <SpawnProjectilesScript>();
     OnChangeClass();
 }
 protected override void Start()
 {
     base.Start();
     this.aim = base.GetComponent <AimIK>();
     this.ik  = base.GetComponent <FullBodyBipedIK>();
     this.aim.Disable();
     this.ik.Disable();
     this.fpsCamDefaultRot = this.firstPersonCam.transform.localRotation;
 }
Esempio n. 12
0
    // Use this for initialization
    void Awake()
    {
        m_AimIK = GetComponent <AimIK>();
//		m_AimIK.Disable();
        //m_FBBIK = GetComponent<FullBodyBipedIK>();
//		m_FBBIK.Disable();
        m_ModelTran      = transform.parent.GetComponentInChildren <PEModelController>().transform;
        m_DetectorCenter = m_AimIK.solver.transform;
        m_DefaultAxis    = m_AimIK.solver.axis;
    }
    // Use this for initialization
    void Awake()
    {
        stateMan  = GetComponent <EnemyStateManager>();
        aimIk     = GetComponent <AimIK>();
        equipMan  = GetComponent <EnemyEquipmentManager>();
        abilities = GetComponent <EnemyAbilities>();

        //条件を否定
        ignoreMask = ~ignoreMask;
    }
Esempio n. 14
0
 // Use this for initialization
 void Awake()
 {
     shootSys  = GetComponent <PlayerShootingSystem>();
     meleeSys  = GetComponent <PlayerMeleeSystem>();
     animator  = GetComponent <Animator>();
     aimIk     = GetComponent <AimIK>();
     stateMan  = GetComponent <PlayerStateManager>();
     aimer     = GetComponent <PlayerAimer>();
     forcusSys = GetComponent <AimForcusSystem>();
 }
Esempio n. 15
0
 public FSMState(Transform player)
 {
     this.player            = player;
     animator               = player.GetComponent <Animator>();
     ik                     = player.GetComponent <AimIK>();
     playerController       = player.GetComponent <PlayerController>();
     characterController    = player.GetComponent <CharacterController>();
     capsuleCollider        = player.GetComponent <CapsuleCollider>();
     PlayerFsm              = player.GetComponent <PlayerFSM>();
     playerRotateWithCamera = player.GetComponent <PlayerRotateWithCamera>();
     playerRayCast          = player.GetComponent <PlayerRayCast>();
     PlayerAudioEffect      = player.GetComponent <PlayerAudioEffect>();
 }
Esempio n. 16
0
        protected override void Start()
        {
            base.Start();

            // Find the IK components
            aim = GetComponent <AimIK>();
            ik  = GetComponent <FullBodyBipedIK>();

            // Disable the IK components to manage their updating
            aim.Disable();
            ik.Disable();

            fpsCamDefaultRot = firstPersonCam.transform.localRotation;
        }
        protected override void Start()
        {
            base.Start();

            // Find the IK components
            aim = GetComponent <AimIK>();
            ik  = GetComponent <FullBodyBipedIK>();

            // Disable the IK components to manage their updating
            aim.enabled = false;
            ik.enabled  = false;

            // Presuming head is rotated towards character forward at Start
            headLookAxis = ik.references.head.InverseTransformVector(ik.references.root.forward);

            // Enable the upper-body aiming pose
            animator.SetLayerWeight(1, 1f);
        }
Esempio n. 18
0
        // Use this for initialization
        void Start()
        {
            try
            {
                PlayerInput = FindObjectOfType <PlayerInput>();
            }
            catch (System.NullReferenceException)
            {
                throw new UnityException("There is no PlayerInput Script. Please add one.");
            }

            controller      = GetComponent <CharacterController>();
            animator        = GetComponent <Animator>();
            aimIK           = GetComponent <AimIK>();
            cameraTransform = Camera.main.transform;
            capsuleHeight   = controller.height;
            capsuleCenter   = controller.center;
            HitColliders    = GetComponentsInChildren <DamageZone>();
        }
    private void OnEnable()
    {
        if (characterAnimator == null)
        {
            characterAnimator = GetComponent <Animator>();
        }
        if (rb == null)
        {
            rb = GetComponent <Rigidbody>();
        }
        //if (rightHandIKAnimator == null) rightHandIKAnimator = rightHandIK.GetComponent<Animator>();

        cameraRig.gameObject.SetActive(true);
        characterAnimator.SetBool("Aiming", true);
        //characterAnimator.SetLayerWeight(characterAnimator.GetLayerIndex("Right Hand IK"), 1f);
        //characterAnimator.SetLayerWeight(characterAnimator.GetLayerIndex("Left Hand IK"), 1f);
        characterAnimator.SetLayerWeight(characterAnimator.GetLayerIndex("Legs"), 1f);

        aimingRigAnimator.Play("Vertical Aiming", 0, verticalAngle);
        aimingRigAnimator.Update(1f);

        if (aimIK == null)
        {
            aimIK = GetComponent <AimIK>();
        }
        if (fbbIK == null)
        {
            fbbIK = GetComponent <FullBodyBipedIK>();
        }
        if (lookAtIK == null)
        {
            lookAtIK = GetComponent <LookAtIK>();
        }
        aimIK.enabled    = false;
        fbbIK.enabled    = false;
        lookAtIK.enabled = false;

        fbbIK.solver.leftArmChain.bendConstraint.weight = 1f;
    }
Esempio n. 20
0
    public void Initialize(Player player)
    {
        if (player)
        {
            _player = player;

            if (transform.Find("Right Arm IK"))
            {
                rightArmAimIK = transform.Find("Right Arm IK").GetComponent <AimIK>();
            }

            if (transform.Find("Left Arm IK"))
            {
                leftArmAimIK = transform.Find("Left Arm IK").GetComponent <AimIK>();
            }

            if (transform.Find("Spine IK"))
            {
                spineAimIK = transform.Find("Spine IK").GetComponent <AimIK>();
            }
        }
    }
        public virtual void Awake()
        {
            m_agentParameters = this.GetComponent <AgentParameters>();
            m_target          = new GameObject();
            m_movmentVector   = new Vector3(0, 0, 0);

            // Create Animation system.
            AimIK aimIK = this.GetComponent <AimIK>();

            aimIK.solver.target = m_target.transform;
            m_animationModule   = new HumanoidAnimationModule(this.GetComponent <Animator>(), this.GetComponent <AimIK>(), 10);

            // Create equipment system.
            Weapon[]     currentWeapons     = this.GetComponentsInChildren <Weapon>();
            WeaponProp[] currentWeaponProps = this.GetComponentsInChildren <WeaponProp>();
            m_equipmentModule = new HumanoidEquipmentModule(currentWeapons, currentWeaponProps, m_characterState, m_target, GetComponent <Recoil>(), m_animationModule, m_agentParameters);

            // Create movment system.
            m_movmentModule = new HumanoidMovmentModule(this.transform, m_characterState, m_target, m_animationModule);

            // Create Damage module
            m_damageModule = new HumanoidDamageModule(5, this.GetComponent <RagdollUtility>(), this.GetComponentInChildren <HitReaction>(), m_animationModule, findHeadTransfrom(), findChestTransfrom(), destroyCharacter, this.GetComponentInChildren <Outline>());
        }
Esempio n. 22
0
 // Use this for initialization
 void Start()
 {
     ik = GetComponent <AimIK>();
 }
Esempio n. 23
0
    // Use this for initialization
    void Start()
    {
        healthBar       = GameObject.Find("HealthBar").GetComponent <RectTransform>();
        gmanager        = GameObject.Find("GameManager").GetComponent <GameManager>();
        maxHealth       = health;
        playerAnimsCont = GetComponent <Animation>();
        playerCol       = GetComponent <CapsuleCollider>();
        PlayerAnimator  = GetComponent <Animator>();
        weppos          = GameObject.FindGameObjectWithTag("WepActiveLoc");
        wepPanel        = GameObject.FindGameObjectWithTag("WeaponsPanel");
        ArmMover        = GameObject.FindGameObjectWithTag("ArmMover");
        PHand           = ArmMover.GetComponent <ArmMover>().playerHand;
        playerarm       = GetComponent <AimIK>();

        GameObject[] arr = GameObject.FindGameObjectsWithTag("PlayerWeapon");
        if (arr.Length < maxWeapons)
        {
            weapons = new GameObject[arr.Length];
        }
        else
        {
            weapons = new GameObject[maxWeapons];
        }

        wepbuts = new Button[wepPanel.GetComponentsInChildren <Button>(true).Length];
        wepbuts = wepPanel.GetComponentsInChildren <Button>(true);

        int count = 0;

        foreach (GameObject arrItem in arr)
        {
            if (arrItem.name == "SMG")
            {
                SMG script = arrItem.GetComponent <SMG>();
                weapons[script.weaponIndex] = arrItem;
                if (script.equiped)
                {
                    wepbuts[script.weaponIndex].gameObject.SetActive(true);
                }
            }

            if (arrItem.name == "Sword")
            {
                Sword script = arrItem.GetComponent <Sword>();
                weapons[script.weaponIndex] = arrItem;
                if (script.equiped)
                {
                    wepbuts[script.weaponIndex].gameObject.SetActive(true);
                }
            }

            if (arrItem.name == "Pistol")
            {
                Pistol script = arrItem.GetComponent <Pistol>();
                weapons[script.weaponIndex] = arrItem;
                if (script.equiped)
                {
                    wepbuts[script.weaponIndex].gameObject.SetActive(true);
                }
            }


            arrItem.SetActive(false);
            count++;
        }

        if (weapons[currentWeaponIndex] != null)
        {
            weapon = weapons[currentWeaponIndex];
        }
        else
        {
            weapon = weapons[0];
        }
    }
Esempio n. 24
0
    private void Start()
    {
        animator        = GetComponent <Animator>();
        aimScript       = GetComponent <AimIK>();
        movementsScript = GetComponent <Movements>();
        camerasScript   = Camera.main.GetComponent <CameraController>();

        // Aiming
        fieldOfViewNormal = Camera.main.fieldOfView;
        // Audio
        audioSource = GetComponent <AudioSource>();

        #region Weapons
        // Fighting mode
        SetFightingModeOff();

        //Sword initiating
        Weapon sword = new MeleeWeapon(
            0,        // index
            "Sword",  // name
            weaponSlot.transform.GetChild(0).gameObject,
            20,       // damage
            2f,       // equip rate
            0.8f,     // holster rate
            (AudioClip)Resources.Load("Sounds/sword_sounds/sword_swish_1")
            );

        // Pistol initiating
        Weapon pistol = new RangedWeapon(
            1,          // index
            "Pistol",   // name
            weaponSlot.transform.GetChild(1).gameObject,
            10,         // magazine capacity
            250f,       // range
            30,         // damage
            0.4f,       // serial rate
            2.167f,     // reload rate
            0.867f,     // equip rate
            1.1f,       // holster rate
            15,         // chargers
            (AudioClip)Resources.Load("Sounds/pistol_sounds/pistol_shot"),
            (AudioClip)Resources.Load("Sounds/pistol_sounds/pistol_reload"),
            weaponSlot.transform.GetChild(1).GetChild(1).GetComponent <ParticleSystem>()
            );

        // Rifle initiating
        Weapon rifle = new RangedWeapon(
            2,         // index
            "Rifle",   // name
            weaponSlot.transform.GetChild(2).gameObject,
            30,        // magazine capacity
            500f,      // range
            50,        // damage
            0.12f,     // serial rate
            2.167f,    // reload rate
            1.8f,      // equip rate
            1.2f,      // holster rate
            10,        // chargers
            (AudioClip)Resources.Load("Sounds/rifle_sounds/m4a4_shot"),
            (AudioClip)Resources.Load("Sounds/rifle_sounds/m4a4_reload"),
            weaponSlot.transform.GetChild(2).GetChild(1).GetComponent <ParticleSystem>()
            );

        currentWeaponObject = new GameObject();
        weapons             = new Weapon[] { sword, pistol, rifle };

        weaponsNames = new string[weapons.Length];

        for (int i = 0; i < weapons.Length; i++)
        {
            weaponsNames[i] = weapons[i].weaponName;
        }

        weaponsAmount = weapons.Length - 1;

        if (weapons.Length > 1)
        {
            for (int i = 0; i <= weaponsAmount; i++)
            {
                weaponSlot.transform.GetChild(i).gameObject.SetActive(false);
            }
        }

        // Default weapon
        currentWeaponNumber   = rifle.weaponIndex;
        currentWeaponInstance = weapons[currentWeaponNumber];
        StartCoroutine(SetWeapon(currentWeaponInstance.equipRate));
        #endregion
    }
Esempio n. 25
0
 // Use this for initialization
 void Start()
 {
     rigidBody = GetComponent <Rigidbody>();
     animator  = GetComponent <Animator>();
     aimIK     = GetComponent <AimIK>();
 }
Esempio n. 26
0
    public override void LoadCharacterModel(string prefabName)
    {
        if (this.Model != null)
        {
            GameObject.Destroy(this.Model);
        }

        GameObject o = GameObject.Instantiate(Resources.Load(prefabName)) as GameObject;

        o.transform.parent           = this.transform;
        o.transform.localPosition    = Vector3.zero;
        o.transform.localEulerAngles = Vector3.zero;

        this.MyAnimator         = o.transform.GetComponent <Animator>();
        this.MyReference        = o.transform.GetComponent <CharacterReference>();
        this.MyAnimEventHandler = o.transform.GetComponent <AnimationEventHandler>();

        this.MyReference.ParentCharacter = this;
        this.MyReference.LiveCollider    = transform.GetComponent <CapsuleCollider>();
        if (this.MyReference.DeathCollider != null)
        {
            this.MyReference.DeathCollider.GetComponent <DeathCollider>().ParentCharacter = this;
            this.MyReference.DeathCollider.enabled = false;
        }

        if (this.MyReference.FixedMeleeLeft != null)
        {
            this.MyReference.FixedMeleeLeft.Attacker = this;
            this.MyReference.FixedMeleeLeft.Rebuild(null, null);
        }

        if (this.MyReference.FixedMeleeRight != null)
        {
            this.MyReference.FixedMeleeRight.Attacker = this;
            this.MyReference.FixedMeleeRight.Rebuild(null, null);
        }

        this.MyAimIK = o.transform.GetComponent <AimIK>();
        this.MyAimIK.solver.target           = AimTarget;
        this.MyAimIK.solver.IKPositionWeight = 0;
        this.MyAimIK.solver.SmoothDisable();

        this.MyLeftHandIK = o.transform.GetComponent <LeftHandIKControl>();
        this.MyLeftHandIK.Initialize();

        this.MyHeadIK = o.transform.GetComponent <HeadIKControl>();
        this.MyHeadIK.Initialize();
        this.MyHeadIK.LookTarget = LookTarget;


        //setup animator parameters initial values
        this.MyAnimator.SetInteger("AlertLevel", 0);

        this.Model      = o;
        this.Model.name = prefabName;

        if (this.MyAI != null)
        {
            this.MyAI.BlackBoard.EquippedWeapon = null;
        }


        //subscribe events
        this.MyAnimEventHandler.OnMeleeStrikeLeftFinish -= OnMeleeStrikeFinish;
        this.MyAnimEventHandler.OnMeleeStrikeLeftFinish += OnMeleeStrikeFinish;

        this.MyAnimEventHandler.OnMeleeStrikeRightFinish -= OnMeleeStrikeFinish;
        this.MyAnimEventHandler.OnMeleeStrikeRightFinish += OnMeleeStrikeFinish;

        this.MyAnimEventHandler.OnMeleeBlocked -= OnMeleeBlocked;
        this.MyAnimEventHandler.OnMeleeBlocked += OnMeleeBlocked;

        this.MyAnimEventHandler.OnHitReover -= OnInjuryRecover;
        this.MyAnimEventHandler.OnHitReover += OnInjuryRecover;

        this.MyAnimEventHandler.OnAnimationActionEnd -= OnAnimationActionEnd;
        this.MyAnimEventHandler.OnAnimationActionEnd += OnAnimationActionEnd;

        this.MyAnimEventHandler.OnMeleeStrikeHalfWay -= OnMeleeStrikeHalfWay;
        this.MyAnimEventHandler.OnMeleeStrikeHalfWay += OnMeleeStrikeHalfWay;

        this.MyAnimEventHandler.OnStartStrangle -= OnStartStrangle;
        this.MyAnimEventHandler.OnStartStrangle += OnStartStrangle;
        this.MyAnimEventHandler.OnEndStrangle   -= OnEndStrangle;
        this.MyAnimEventHandler.OnEndStrangle   += OnEndStrangle;

        this.MyAnimEventHandler.OnFootStep -= OnFootStep;
        this.MyAnimEventHandler.OnFootStep += OnFootStep;
    }
Esempio n. 27
0
 void Awake()
 {
     m_AimIK = GetComponent <AimIK>();
 }
 public HumanoidAnimationModule(Animator animator, AimIK m_aimIK, float AimSpeed) : base(animator)
 {
     this.m_aimIK = m_aimIK;
     m_aimSpeed   = AimSpeed;
 }