Пример #1
0
    void OnCollisionEnter(Collision collision)
    {
        PlayerZhiShengJiCtrl playerScript = collision.gameObject.GetComponent <PlayerZhiShengJiCtrl>();

        if (playerScript == null)
        {
            return;
        }

        if (IsDeathNpc)
        {
            return;
        }
//		Debug.Log("**********OnCollisionEnter-> collision "+collision.gameObject.name);

        if (playerScript.GetPlayerType() != PlayerTypeEnum.TanKe)
        {
            return;
        }

        if (XkGameCtrl.GameJiTaiSt != GameJiTaiType.TanKeJiTai)
        {
            return;
        }

        bool isSetDianJiState = false;

        if (!IsYouTongNpc)
        {
            isSetDianJiState = true;
            XkGameCtrl.GetInstance().AddPlayerKillNpc(PlayerEnum.Null, NpcJiFen);
            XkGameCtrl.GetInstance().AddYouLiangDian(YouLiangDian, PlayerEnum.Null);
            YouLiangDianUICtrl.GetInstance().HandleNpcYouLiangDian(YouLiangDian, transform);
        }

        if (NpcScript != null)
        {
            IsDeathNpc       = true;
            isSetDianJiState = true;
            NpcScript.TriggerRemovePointNpc(1);
        }
        else if (CannonScript != null)
        {
            IsDeathNpc       = true;
            isSetDianJiState = true;
            CannonScript.OnRemoveCannon(PlayerEnum.Null, 1);
        }

        if (isSetDianJiState)
        {
            XKPlayerAutoFire.SetPlayerZuoYiDianJiState(PlayerEnum.PlayerOne, 2);
            XKPlayerAutoFire.SetPlayerZuoYiDianJiState(PlayerEnum.PlayerTwo, 2);
        }
        CheckHiddenNpcObjArray();
    }
    // Use this for initialization
    void Start()
    {
        _Instance = this;

        YouLiangDianMoveCtrl yldScript = null;

        for (int i = 0; i < 20; i++)
        {
            yldScript = YouLiangDianUICtrl.GetInstance().SpawnYouLiangDianUI(YouLiangDengJi.Level_1);
            XkGameCtrl.AddYLDLv(yldScript);
            yldScript.gameObject.SetActive(false);
            if (i < 5)
            {
                yldScript = YouLiangDianUICtrl.GetInstance().SpawnYouLiangDianUI(YouLiangDengJi.Level_2);
                XkGameCtrl.AddYLDLv(yldScript);
                yldScript.gameObject.SetActive(false);

                yldScript = YouLiangDianUICtrl.GetInstance().SpawnYouLiangDianUI(YouLiangDengJi.Level_3);
                XkGameCtrl.AddYLDLv(yldScript);
                yldScript.gameObject.SetActive(false);
            }
        }
    }
Пример #3
0
    public void OnDamageNpc(PlayerAmmoType state, PlayerEnum playerSt)
    {
        if (IsDeathNpc)
        {
            return;
        }

        if (NpcScript == null || (NpcScript != null && !NpcScript.GetIsWuDi()))
        {
            switch (state)
            {
            case PlayerAmmoType.PuTongAmmo:
                PuTongAmmoCount++;
                break;

            case PlayerAmmoType.GaoBaoAmmo:
                GaoBaoAmmoCount++;
//				Debug.Log(gameObject.name+":: GaoBaoAmmoCount "+GaoBaoAmmoCount+", MaxGaoBaoAmmo "+MaxGaoBaoAmmo
//				          +", playerSt "+playerSt);
                break;

            case PlayerAmmoType.DaoDanAmmo:
                DaoDanAmmoCount++;
//				Debug.Log(gameObject.name+":: DaoDanAmmoCount "+MaxDaoDanAmmo+", MaxGaoBaoAmmo "+MaxDaoDanAmmo
//				          +", playerSt "+playerSt);
                break;
            }
        }

        if (NpcShouJiFanKui != null)
        {
            NpcShouJiFanKui.PlayNpcDamageEvent();
        }

        AmmoHurtCount++;
        if (MaxAmmoHurtLiZi > 0 && AmmoHurtCount >= MaxAmmoHurtLiZi)
        {
            if (HurtLiZiObj != null && !HurtLiZiObj.activeSelf)
            {
                HurtLiZiObj.SetActive(true);
            }
        }

        int puTongAmmoNum = MaxPuTongAmmo;         //单机单人.

        if (XkGameCtrl.GameModeVal == GameMode.LianJi &&
            XkPlayerCtrl.PlayerTranFeiJi != null &&
            XkPlayerCtrl.PlayerTranTanKe != null)
        {
            if (XkGameCtrl.IsActivePlayerOne && XkGameCtrl.IsActivePlayerTwo)
            {
                puTongAmmoNum = LJMaxPuTongAmmoSR;                 //联机双人.
            }
            else
            {
                puTongAmmoNum = LJMaxPuTongAmmoSR;                 //联机单人.
            }
        }
        else
        {
            if (XkGameCtrl.IsActivePlayerOne && XkGameCtrl.IsActivePlayerTwo)
            {
                puTongAmmoNum = MaxPuTongAmmoSR;                 //单机双人.
            }
        }

        if (PuTongAmmoCount >= puTongAmmoNum ||
            GaoBaoAmmoCount >= MaxGaoBaoAmmo ||
            DaoDanAmmoCount >= MaxDaoDanAmmo)
        {
            if (IsDeathNpc)
            {
                return;
            }
            IsDeathNpc = true;
            CheckHiddenNpcObjArray();

            bool isAddKillNpcNum = true;
            if (NpcScript != null && CannonScript != null)
            {
                if (NpcScript.GetIsDeathNPC())
                {
                    isAddKillNpcNum = false;
                }
            }

            if (!IsYouTongNpc)
            {
                if (Network.peerType != NetworkPeerType.Server)
                {
                    if (isAddKillNpcNum)
                    {
                        XkGameCtrl.GetInstance().AddPlayerKillNpc(playerSt, NpcJiFen);
                    }
                    XkGameCtrl.GetInstance().AddYouLiangDian(YouLiangDian, playerSt);

                    if (YouLiangDianUICtrl.GetInstance() != null)
                    {
                        YouLiangDianUICtrl.GetInstance().HandleNpcYouLiangDian(YouLiangDian, transform);
                    }
                }
            }
            else
            {
                if (playerSt != PlayerEnum.Null)
                {
                    CheckYouTongDamageNpc();
                }
            }

            if (NpcScript != null)
            {
                if (CannonScript != null)
                {
                    CannonScript.OnRemoveCannon(playerSt, 1);
                }
                NpcScript.TriggerRemovePointNpc(1, CannonScript);
            }
            else if (CannonScript != null)
            {
                CannonScript.OnRemoveCannon(playerSt, 1);
            }
        }
    }