public void SetSpawnPointScript(XKSpawnNpcPoint script)
    {
        IsHandleRpc      = true;
        SpawnPointScript = script;
        IsHuoCheNpc      = SpawnPointScript.GetIsHuoCheNpc();
//		Debug.Log("Unity:"+"SetSpawnPointScript -> IsHuoCheNpc "+IsHuoCheNpc);
        TestSpawnPoint = script.gameObject;

        if (CannonScript == null || CannonScript.Length < 1)
        {
            CannonScript = gameObject.GetComponentsInChildren <XKCannonCtrl>();
        }

        if (CannonScript.Length > 0)
        {
            int max = CannonScript.Length;
//			Debug.Log("Unity:"+"SetSpawnPointScript -> max "+max);
            for (int i = 0; i < max; i++)
            {
                CannonScript[i].SetSpawnPointScript(this);
            }
            SetCannonAimPlayerState();
        }
        transform.SetParent(XkGameCtrl.NpcObjArray);
        SendNpcTransformInfo();
    }
    // Use this for initialization
    void Start()
    {
        int max = SpawnPoint.Length;

        if (max <= 0)
        {
            Debug.LogWarning("Unity:" + "SpawnPoint.len is wrong!");
            GameObject obj = null;
            obj.name = "null";
            return;
        }

        XKSpawnNpcPoint script = null;

        for (int i = 0; i < max; i++)
        {
            if (SpawnPoint[i] == null)
            {
                Debug.LogWarning("Unity:" + "SpawnPoint is wrong! index is " + i);
                GameObject obj = null;
                obj.name = "null";
                break;
            }

            script = SpawnPoint[i].GetComponent <XKSpawnNpcPoint>();
            script.SetIsPlayerLeaveTrigger();
        }
        XkGameCtrl.GetInstance().ChangeBoxColliderSize(transform);
    }
Beispiel #3
0
    void SetOtherPortHuoCheNpcInfo(XKSpawnNpcPoint pointScript, int indexPoint)
    {
        if (Network.peerType != NetworkPeerType.Server)
        {
            return;
        }

        GameObject npcObj = pointScript.GetNpcLoopObj();

        if (pointScript == null || npcObj == null)
        {
            return;
        }

        XKDaPaoCtrl daPaoScript = npcObj.GetComponent <XKDaPaoCtrl>();

        if (daPaoScript != null)
        {
            daPaoScript.SetHuoCheNpcInfo(indexPoint);
        }
        else
        {
            XKNpcMoveCtrl npcScript = npcObj.GetComponent <XKNpcMoveCtrl>();
            if (npcScript != null)
            {
                npcScript.SetHuoCheNpcInfo(indexPoint);
            }
        }
    }
Beispiel #4
0
    void Start()
    {
        Instance = this;
        if (XkGameCtrl.GetInstance().IsCartoonShootTest)
        {
            if (TestSpawnPoint != null)
            {
                XKSpawnNpcPoint spawnCom = TestSpawnPoint.GetComponent <XKSpawnNpcPoint>();
                if (spawnCom != null)
                {
                    SetHuoCheInfo(spawnCom);
                }
            }
        }

        if (transform.parent == null)
        {
            transform.parent = XkGameCtrl.NpcDtArray;
            NpcObj           = gameObject;
            AnimatorTran     = AnimatorCom.transform;
            NpcTran          = transform;
        }

//		if (NetViewCom == null) {
//			NetViewCom = GetComponent<NetworkView>();
//		}
    }
Beispiel #5
0
 public void RemoveAimSpawnPoint(XKSpawnNpcPoint script)
 {
     if (!AimSpawnPoint.Contains(script))
     {
         return;
     }
     AimSpawnPoint.Remove(script);
 }
Beispiel #6
0
 void AddAimSpawnPoint(XKSpawnNpcPoint script)
 {
     if (AimSpawnPoint.Contains(script))
     {
         return;
     }
     AimSpawnPoint.Add(script);
 }
 void Start()
 {
     m_SpawnPoint = gameObject.GetComponent <XKSpawnNpcPoint>();
     if (transform.childCount > 0)
     {
         Destroy(transform.GetChild(0).gameObject);
     }
 }
Beispiel #8
0
	void DelaySetRigidbodyInfo()
	{
		Rigidbody rig = GetComponent<Rigidbody>();
		if (rig != null) {
			rig.isKinematic = true;
			rig.useGravity = true;
		}
		
		if (SpawnPointScript == null) {
			SpawnPointScript = NpcScript.GetSpawnPointScript();
		}
	}
Beispiel #9
0
    public void SetHuoCheInfo(XKSpawnNpcPoint script)
    {
        IsHandleRpc = true;
//		NetViewCom = GetComponent<NetworkView>();
        SpawnPointScript   = script;
        transform.position = SpawnPointScript.transform.position;
        transform.rotation = SpawnPointScript.transform.rotation;
        TestSpawnPoint     = SpawnPointScript.gameObject;
//		SendHuoCheTranInfo(SpawnPointScript.HuoCheNpcTran.position, SpawnPointScript.HuoCheNpcTran.rotation);

        XKNpcMoveCtrl[] npcMoveScript = GetComponentsInChildren <XKNpcMoveCtrl>();
        int             max           = npcMoveScript.Length;

        if (max > 0)
        {
            for (int i = 0; i < max; i++)
            {
                npcMoveScript[i].SetSpawnPointScript(script);
            }
        }

        XKCannonCtrl[] npcCannonScript = GetComponentsInChildren <XKCannonCtrl>();
        max = npcCannonScript.Length;
        if (max > 0)
        {
            for (int i = 0; i < max; i++)
            {
                npcCannonScript[i].SetSpawnPointScript(null);
            }
            SetCannonAimPlayerState();
        }

        XKSpawnNpcPoint[] pointScript = GetComponentsInChildren <XKSpawnNpcPoint>();
        //Debug.Log("pointScript.Len "+pointScript.Length);
        max = pointScript.Length;
        if (max > 0)
        {
            //for (int i = 0; i < 1; i++) { //test
            for (int i = 0; i < max; i++)
            {
                pointScript[i].SetIsHuoCheNpc();
                pointScript[i].SpawnPointAllNpc();
                SetOtherPortHuoCheNpcInfo(pointScript[i], i);
            }
        }

        StartMoveHuoChe(script.NpcPath);
    }
    public static void HandleFeiJiNpcSpawnInfo(XKNpcMoveCtrl npcScript, int indexVal)
    {
        if (FiJiNpcPointList == null)
        {
            return;
        }

        if (indexVal >= FiJiNpcPointList.Count)
        {
            return;
        }

        //Debug.Log("Unity:"+"HandleFeiJiNpcSpawnInfo -> indexVal "+indexVal);
        XKSpawnNpcPoint spawnScript = FiJiNpcPointList[indexVal];

        spawnScript.SaveFeiJiNpcSpawnInfo(npcScript);
    }
    public GameObject GetNpcObjFromNpcDtList(XKSpawnNpcPoint spawnCom, GameObject npcPrefab, Vector3 pos, Quaternion rot)
    {
        if (npcPrefab == null)
        {
            return(null);
        }

        GameObject npcObj = null;
        int        max    = NpcDtList.Count;

        if (max > 0)
        {
            for (int i = 0; i < max; i++)
            {
                if (NpcDtList[i] != null && NpcDtList[i].NpcPrefabName == npcPrefab.name)
                {
                    npcObj = NpcDtList[i].FindNpcObjFromNpcList(spawnCom, npcPrefab);
                    break;
                }
            }
        }

        if (npcObj == null)
        {
            //Debug.Log("Unity:"+"GetNpcObjFromNpcDtList -> npcPrefabName is "+npcPrefab.name);
            GameObject       objNpcSpawnList = new GameObject("XKNpcSpawnListDt");
            XKNpcSpawnListDt npcSpawnList    = objNpcSpawnList.AddComponent <XKNpcSpawnListDt>();
            HandleNpcDtList(npcSpawnList);
            Transform tran = objNpcSpawnList.transform;
            tran.parent = transform;
            npcObj      = npcSpawnList.FindNpcObjFromNpcList(spawnCom, npcPrefab);
            if (npcObj == null)
            {
                HandleRemoveNpcDtList(npcSpawnList);
            }
        }

        if (npcObj != null)
        {
            //Transform npcTran = npcObj.transform;
            npcObj.transform.position = pos;
            npcObj.transform.rotation = rot;
            //Debug.Log("Unity:"+npcObj.name+", id "+npcObj.GetInstanceID()+", pos "+pos+", rot "+rot);
        }
        return(npcObj);
    }
    void OnTriggerEnter(Collider other)
    {
        XkPlayerCtrl  playerScript = other.GetComponent <XkPlayerCtrl>();
        XKNpcMoveCtrl npcScript    = other.GetComponent <XKNpcMoveCtrl>();

        if (npcScript != null)
        {
            /*if (!npcScript.IsAniMove) {
             *      return;
             * }*/

            if (npcScript.TestSpawnPoint == null)
            {
                return;
            }

            XKSpawnNpcPoint spawnNpcPoint = npcScript.TestSpawnPoint.GetComponent <XKSpawnNpcPoint>();
            if (spawnNpcPoint == null)
            {
                return;
            }

            if (SpawnPoint[0] != spawnNpcPoint)
            {
                return;
            }
            playerScript = XkPlayerCtrl.GetInstanceFeiJi();
        }

        if (playerScript == null)
        {
            return;
        }

        int max = SpawnPoint.Length;

        for (int i = 0; i < max; i++)
        {
            if (SpawnPoint[i] != null)
            {
                playerScript.RemoveAimSpawnPoint(SpawnPoint[i]);
            }
        }
    }
    public void SetSpawnNpcInfo(XKSpawnNpcPoint spawnScript)
    {
        transform.SetParent(XkGameCtrl.NpcObjArray);
        NetViewCom       = GetComponent <NetworkView>();
        SpawnPointScript = spawnScript;
//		SetAimState();
        TestSpawnPoint = spawnScript.gameObject;
        if (spawnScript.NpcPath != null)
        {
            NpcPathScript = spawnScript.NpcPath.GetComponent <NpcPathCtrl>();
        }

        NpcObj       = gameObject;
        NpcTran      = transform;
        NpcPathTran  = spawnScript.NpcPath;
        MvSpeed      = spawnScript.MvSpeed;
        FireDistance = spawnScript.FireDistance;

        if (IsDeathNPC)
        {
            IsDeathNPC     = false;
            IsHiddenNpcObj = false;
        }

        //SetNpcFireAnimationIsAimFeiJiPlayer(spawnScript.IsAimFeiJiPlayer);

        NpcMoveScript = NpcTran.GetComponentsInChildren <XKNpcMoveCtrl>();
        for (int i = 0; i < NpcMoveScript.Length; i++)
        {
            NpcMoveScript[i].SetIsFangZhenNpc(this, i);
            NpcMoveScript[i].SetNpcSpawnScriptInfo(spawnScript);
            NpcMoveScript[i].SetIndexNpc(i);
        }
        FangZhenNpcCount = NpcMoveScript.Length;
        //Debug.Log("Unity:"+"SetSpawnNpcInfo -> FangZhenNpcCount "+FangZhenNpcCount+", fangZhenObj "+NpcObj.name);

        if (spawnScript.TimeRootAni > 0f)
        {
            PlayNpcAnimation(spawnScript.AniRootName);
        }
        StartCoroutine(StartMoveNpcByItween(spawnScript.AniRunName, spawnScript.TimeRootAni));
    }
    void Start()
    {
        if (CannonScript == null || CannonScript.Length < 1)
        {
            CannonScript = gameObject.GetComponentsInChildren <XKCannonCtrl>();
        }

        //Debug.Log("Unity:"+"name "+gameObject.name+", IsHuoCheNpc "+IsHuoCheNpc);
        if (XkGameCtrl.GetInstance().IsCartoonShootTest)
        {
            if (TestSpawnPoint != null)
            {
                XKSpawnNpcPoint spawnPoint = TestSpawnPoint.GetComponent <XKSpawnNpcPoint>();
                if (spawnPoint != null)
                {
                    SetSpawnPointScript(spawnPoint);
                }
            }
        }
        Invoke("DelayChangeNpcParent", 0.2f);
    }
//#endif

    public void CleanEmptySpawnPointGroup()
    {
        Transform trTmp = null;

        XKSpawnNpcPoint[]      spawnScriptArray     = null;
        XKSpawnNpcPointGroup[] spawnPointGroupArray = GameObject.FindObjectsOfType(typeof(XKSpawnNpcPointGroup)) as XKSpawnNpcPointGroup[];
        if (spawnPointGroupArray == null)
        {
            //Debug.Log("Unity:"+"CleanEmptySpawnPointGroup -> spawnPointGroupArray is null");
            return;
        }
        //Debug.Log("Unity:"+"CleanEmptySpawnPointGroup -> spawnPointGroupArray.Length "+spawnPointGroupArray.Length);
        List <XKSpawnNpcPointGroup> spawnPointGroupList = new List <XKSpawnNpcPointGroup>(spawnPointGroupArray)
        {
        };

        bool isFindEmptySpawnPoint = false;

        do
        {
            isFindEmptySpawnPoint = false;

            for (int i = 0; i < spawnPointGroupList.Count; i++)
            {
                trTmp = spawnPointGroupList[i].transform;
                trTmp.gameObject.layer = LayerMask.NameToLayer("TransparentFX");
                if (trTmp.childCount <= 0)
                {
                    isFindEmptySpawnPoint = true;
                }
                else
                {
                    Transform[]      trArrayTmp = trTmp.GetComponentsInChildren <Transform>();
                    List <Transform> trListTmp  = new List <Transform>(trArrayTmp)
                    {
                    };
                    for (int j = 1; j < trListTmp.Count; j++)
                    {
                        XKSpawnNpcPoint spawnPointTmp = trListTmp[j].GetComponent <XKSpawnNpcPoint>();
                        if (spawnPointTmp == null)
                        {
                            trListTmp[j].parent = trTmp.parent;
                        }
                    }

                    spawnScriptArray = spawnPointGroupList[i].gameObject.GetComponentsInChildren <XKSpawnNpcPoint>();
                    if (spawnScriptArray.Length <= 0)
                    {
                        isFindEmptySpawnPoint = true;
                    }
                }

                if (isFindEmptySpawnPoint)
                {
                    DestroyImmediate(spawnPointGroupList[i].gameObject);
                    spawnPointGroupList.RemoveAt(i);
                    break;
                }
            }
        } while(isFindEmptySpawnPoint);
    }
    public GameObject FindNpcObjFromNpcList(XKSpawnNpcPoint spawnCom, GameObject npcPrefab)
    {
        if (npcPrefab == null)
        {
            return(null);
        }

        GameObject        npcObj            = null;
        int               max               = NpcList.Count;
        XKNpcMoveCtrl     npcMoveScript     = null;
        XKDaPaoCtrl       npcDaPaoScript    = null;
        XKHuoCheCtrl      npcHuoCheScript   = null;
        XKNpcFangZhenCtrl npcFangZhenScript = null;

        if (max > 0 && NpcScriptSt != NpcScriptState.XKHuoChe)
        {
            for (int i = 0; i < max; i++)
            {
                if (NpcList[i] != null)
                {
                    switch (NpcScriptSt)
                    {
                    case NpcScriptState.XKNpcMove:
                        npcMoveScript = NpcList[i].GetComponent <XKNpcMoveCtrl>();
                        if (npcMoveScript != null &&
                            npcMoveScript.GetIsDeathNPC())
                        {
                            GameObject realNpcObj = npcMoveScript.RealNpcTran.gameObject;
                            if (!realNpcObj.activeSelf)
                            {
                                npcObj = NpcList[i];
                            }
                        }
                        break;

                    case NpcScriptState.XKDaPao:
                        npcDaPaoScript = NpcList[i].GetComponent <XKDaPaoCtrl>();
                        if (npcDaPaoScript != null &&
                            npcDaPaoScript.GetIsDeathNpc())
                        {
                            npcDaPaoScript.SetSpawnPointScript(spawnCom);
                            npcDaPaoScript.ResetNpcDaPaoInfo();
                            npcObj = NpcList[i];
                        }
                        break;

                    case NpcScriptState.XKHuoChe:
                        break;

                    case NpcScriptState.XKFangZhen:
                        npcFangZhenScript = NpcList[i].GetComponent <XKNpcFangZhenCtrl>();
                        if (npcFangZhenScript != null &&
                            npcFangZhenScript.GetIsHiddenNpcObj() &&
                            !npcFangZhenScript.GetIsActiveFangZhen())
                        {
                            npcObj = NpcList[i];
                            npcFangZhenScript.ActiveFangZhenNpc();
                        }
                        break;
                    }
                }

                if (npcObj != null)
                {
                    break;
                }
            }
        }

        if (npcObj == null)
        {
            if (NpcScriptSt == NpcScriptState.Null)
            {
                npcMoveScript = npcPrefab.GetComponent <XKNpcMoveCtrl>();
                if (npcMoveScript != null)
                {
                    NpcScriptSt = NpcScriptState.XKNpcMove;
                }

                if (NpcScriptSt == NpcScriptState.Null)
                {
                    npcDaPaoScript = npcPrefab.GetComponent <XKDaPaoCtrl>();
                    if (npcDaPaoScript != null)
                    {
                        NpcScriptSt = NpcScriptState.XKDaPao;
                    }
                }

                if (NpcScriptSt == NpcScriptState.Null)
                {
                    npcHuoCheScript = npcPrefab.GetComponent <XKHuoCheCtrl>();
                    if (npcHuoCheScript != null)
                    {
                        NpcScriptSt = NpcScriptState.XKHuoChe;
                    }
                }

                if (NpcScriptSt == NpcScriptState.Null)
                {
                    npcFangZhenScript = npcPrefab.GetComponent <XKNpcFangZhenCtrl>();
                    if (npcFangZhenScript != null)
                    {
                        NpcScriptSt = NpcScriptState.XKFangZhen;
                    }
                }
            }

            switch (NpcScriptSt)
            {
            case NpcScriptState.XKNpcMove:
                npcObj = SpawnNpcByNpcPrefab(npcPrefab);
                break;

            case NpcScriptState.XKDaPao:
                npcObj = SpawnNpcByNpcPrefab(npcPrefab);
                break;

            case NpcScriptState.XKHuoChe:
                npcObj = SpawnNpcByNpcPrefab(npcPrefab);
                break;

            case NpcScriptState.XKFangZhen:
                npcObj = SpawnNpcByNpcPrefab(npcPrefab);
                break;
            }
        }
        return(npcObj);
    }