예제 #1
0
 public void InitGun(SoldierGun gunInfo)
 {
     name                    = gunInfo.name;
     bullet                  = gunInfo.bullet;
     range                   = gunInfo.range;
     magazineCountMin        = gunInfo.magazineCountMin;
     magaznieCountMax        = gunInfo.magaznieCountMax;
     fireTimeMin             = gunInfo.fireTimeMin;
     fireTimeMax             = gunInfo.fireTimeMax;
     fireLoopBulletCountMin  = gunInfo.fireLoopBulletCountMin;
     fireLoopBulletCountMax  = gunInfo.fireLoopBulletCountMax;
     betweenFireLoopsTimeMin = gunInfo.betweenFireLoopsTimeMin;
     betweenFireLoopsTimeMax = gunInfo.betweenFireLoopsTimeMax;
     soundsFire              = gunInfo.soundsFire;
     soundsReload            = gunInfo.soundsReload;
 }
예제 #2
0
    public void Init()
    {
        childSkinnedMeshRenderers = GetComponentsInChildren <SkinnedMeshRenderer>();

        childMeshRenderers = GetComponentsInChildren <MeshRenderer>();

        charInfo = GetComponent <CharacterInfo>();
        bodyInfo = GetComponentInChildren <SoldierBodyInfo>();

        body = bodyInfo.gameObject;

        //fullAnimationsClip = bodyInfo.fullAnimsClip;

        charInfo.shootRaycastTargets = bodyInfo.shootRaycastTargets;

        Vector3 oldPos;

        CharacterController soldGenInfoCharController = soldierGeneralInfo.GetComponent <CharacterController>();

        charController = gameObject.AddComponent <CharacterController>();

        charController.center     = soldGenInfoCharController.center;
        charController.slopeLimit = soldGenInfoCharController.slopeLimit;
        charController.stepOffset = soldGenInfoCharController.stepOffset;
        charController.radius     = soldGenInfoCharController.radius;
        charController.height     = soldGenInfoCharController.height;

        //soldierRoot = bodyInfo.soldierRoot;
        //soldierUpperBodyRoot = bodyInfo.soldierUpperBodyRoot;
        //soldierGunRoot = bodyInfo.soldierGunRoot;
        soldierGunFireTr = bodyInfo.soldierGunFireTr;
        animObject       = bodyInfo.SoldierAnimObject;

        soldierEye = bodyInfo.soldierEyeTr;

        movementInfos = soldierGeneralInfo.movementInfos;
        idleInfos     = soldierGeneralInfo.idleInfos;

        //voiceAudioSource = GameObject.Instantiate(soldierGeneralInfo.AudioSource_Voice) as AudioSource;
        //oldPos = voiceAudioSource.transform.position;
        //voiceAudioSource.transform.parent = gameObject.transform;
        //voiceAudioSource.transform.localPosition = oldPos;

        //footStepsAudioSource = GameObject.Instantiate(soldierGeneralInfo.AudioSource_FootSteps) as AudioSource;
        //oldPos = footStepsAudioSource.transform.position;
        //footStepsAudioSource.transform.parent = gameObject.transform;
        //footStepsAudioSource.transform.localPosition = oldPos;

        //gunAudioSource = GameObject.Instantiate(soldierGeneralInfo.AudioSource_Gun) as AudioSource;
        //oldPos = gunAudioSource.transform.position;
        //gunAudioSource.transform.parent = gameObject.transform;
        //gunAudioSource.transform.localPosition = oldPos;

        if (charInfo.FightSide == FightSideEnum.Ally)
        {
            voiceAudioInfo = GameObject.Instantiate(soldierGeneralInfo.AudioInfo_Ally_Voice) as AudioInfo;
        }
        else
        {
            voiceAudioInfo = GameObject.Instantiate(soldierGeneralInfo.AudioInfo_Voice) as AudioInfo;
        }
        oldPos = voiceAudioInfo.transform.position;
        voiceAudioInfo.transform.parent        = gameObject.transform;
        voiceAudioInfo.transform.localPosition = oldPos;

        if (charInfo.FightSide == FightSideEnum.Ally)
        {
            footStepsAudioInfo = GameObject.Instantiate(soldierGeneralInfo.AudioInfo_Ally_FootSteps) as AudioInfo;
        }
        else
        {
            footStepsAudioInfo = GameObject.Instantiate(soldierGeneralInfo.AudioInfo_FootSteps) as AudioInfo;
        }
        oldPos = footStepsAudioInfo.transform.position;
        footStepsAudioInfo.transform.parent        = gameObject.transform;
        footStepsAudioInfo.transform.localPosition = oldPos;

        if (charInfo.FightSide == FightSideEnum.Ally)
        {
            gunAudioInfo = GameObject.Instantiate(soldierGeneralInfo.AudioInfo_Ally_Gun) as AudioInfo;
        }
        else
        {
            gunAudioInfo = GameObject.Instantiate(soldierGeneralInfo.AudioInfo_Gun) as AudioInfo;
        }
        oldPos = gunAudioInfo.transform.position;
        gunAudioInfo.transform.parent        = gameObject.transform;
        gunAudioInfo.transform.localPosition = oldPos;

        charInfo.fightHaloRaycastTargets = new Transform[soldierGeneralInfo.fightHaloRaycastTargets.Length];

        for (int i = 0; i < soldierGeneralInfo.fightHaloRaycastTargets.Length; i++)
        {
            Transform tr = GameObject.Instantiate(soldierGeneralInfo.fightHaloRaycastTargets[i]) as Transform;
            oldPos           = tr.position;
            tr.parent        = gameObject.transform;
            tr.localPosition = oldPos;

            charInfo.fightHaloRaycastTargets[i] = tr;
        }

        InitAStar();

        mapLogic = MapLogic.Instance;
        mapLogic.AddChar(gameObject);

        //soundPlay_VoiceMain.Init(voiceAudioSource);
        ResetVoiceBusyTimeCounter();

        //soundPlay_VoiceMain.OnPlay += ResetVoiceBusyTimeCounter;

        gun = gameObject.AddComponent <SoldierGun>();
        gun.InitGun(gunInfo);
        //gun.InitAudioSource(gunAudioSource);
        gun.InitAudioInfo(gunAudioInfo);

        fightRange = Mathf.Min(gun.range, charInfo.Range);

        footStepRaycastStartTr = soldierGeneralInfo.footRayCastStartTr;
        footStepRaycastEndTr   = soldierGeneralInfo.footRayCastEndTr;

        footStepDelayGraph = soldierGeneralInfo.footStepDelayGraph;
        footStepSoundList  = soldierGeneralInfo.footStepSoundList;

        soldHead = charInfo.characterHead;

        if (PlayerCharacterNew.Instance != null)
        {
            plHead = PlayerCharacterNew.Instance.gameObject.GetComponent <CharacterInfo>().characterHead;
            //plLeftView = PlayerCharacterNew.Instance.leftViewTr;
            //plRightView = PlayerCharacterNew.Instance.rightViewTr;
        }

        isInited = true;
    }
예제 #3
0
 public static Vector3 GetShootingRaycastPos(Vector3 _basePos, Quaternion _baseRot, SoldierFightInPointInfo _info, SoldierGun _gun)
 {
     return(GetShootingRaycastPos(_basePos, _baseRot, _info.GetRaycastOffsetForGun(_gun.name)));
 }