float CheckAiPlayerMoveSpeed()
    {
        float speed = 0f;

        if (CountSpeed == 0)
        {
            speed = Random.Range(0.1f * WaterwheelPlayerNetCtrl.mMaxVelocityFoot, 0.3f * WaterwheelPlayerNetCtrl.mMaxVelocityFoot);
        }
        else
        {
            int   PlayerOneNo = PlayerRankData.PlayerOneDt.RankNo;
            float speedA      = 0f;
            float speedB      = 0f;
            if (RankNoAi < PlayerOneNo)
            {
                speedA = GameNetCtrlXK.GetInstance().AiMinMoveSpeedA *WaterwheelPlayerNetCtrl.mMaxVelocityFoot;
                speedB = GameNetCtrlXK.GetInstance().AiMinMoveSpeedB *WaterwheelPlayerNetCtrl.mMaxVelocityFoot;
            }
            else
            {
                speedA = GameNetCtrlXK.GetInstance().AiMaxMoveSpeedA *WaterwheelPlayerNetCtrl.mMaxVelocityFoot;
                speedB = GameNetCtrlXK.GetInstance().AiMaxMoveSpeedB *WaterwheelPlayerNetCtrl.mMaxVelocityFoot;
            }
            speed = Random.Range(speedA, speedB);
        }
        speed = Mathf.Floor(speed);

        if (speed < 10f)
        {
            speed = 10f;
        }
        CountSpeed++;
        return(speed);
    }
Beispiel #2
0
    void CreateAiPlayer()
    {
        if (LinkServerCount + RankingCtrl.ServerPlayerRankNum >= RankingCtrl.MaxPlayerRankNum)
        {
            return;
        }

        int aiPlayerMax = RankingCtrl.MaxPlayerRankNum - RankingCtrl.ServerPlayerRankNum - LinkServerCount;
        int aiPosNum    = RankingCtrl.ServerPlayerRankNum + LinkServerCount;

        GameObject            obj;
        Transform             tran;
        GameObject            player;
        WaterwheelAiPlayerNet playerScript;

        for (int i = 0; i < aiPlayerMax; i++)
        {
            obj          = GameNetCtrlXK.GetInstance().NpcObj[i];
            tran         = GameNetCtrlXK.GetInstance().PlayerPos[aiPosNum].transform;
            player       = (GameObject)Network.Instantiate(obj, tran.position, tran.rotation, GlobalData.NetWorkGroup);
            playerScript = player.GetComponent <WaterwheelAiPlayerNet>();
            playerScript.SetIsHandlePlayer();

            aiPosNum++;
        }
        LinkServerCount = 0;
    }
Beispiel #3
0
    IEnumerator CheckServerInitialized()
    {
        bool isCheck = true;

        while (isCheck)
        {
            yield return(new WaitForSeconds(0.1f));

            if (Application.loadedLevel != (int)GameLeve.WaterwheelNet || Network.peerType == NetworkPeerType.Disconnected)
            {
                if (Toubi.GetInstance() != null &&
                    !Toubi.GetInstance().IsIntoPlayGame)
                {
                    Toubi.GetInstance().IsIntoPlayGame = true;
                }
                continue;
            }
            isCheck = false;
        }

        if (NetworkRpcMsgCtrl.GetInstance() != null)
        {
            NetworkRpcMsgCtrl.GetInstance().RemoveSelf();
        }

        GameObject obj    = GameNetCtrlXK.GetInstance().PlayerObj[0];
        Transform  tran   = GameNetCtrlXK.GetInstance().PlayerPos[0].transform;
        GameObject player = (GameObject)Network.Instantiate(obj, tran.position, tran.rotation, GlobalData.NetWorkGroup);
        WaterwheelPlayerNetCtrl playerScript = player.GetComponent <WaterwheelPlayerNetCtrl>();

        playerScript.SetIsHandlePlayer();

        //create AiPlayer
        CreateAiPlayer();
    }
Beispiel #4
0
    void CreateDaoJuNet()
    {
        GameObject objPrefab = null;
        string     type      = "";

        switch (DaoJuType)
        {
        case DaoJuState.DianDaoFu:
            if (Network.connections.Length < 1)
            {
                return;
            }
            type      = "DianDaoFuObj";
            objPrefab = GameNetCtrlXK.GetInstance().DianDaoFuNetPrefab;
            break;

        case DaoJuState.DingShenFu:
            type      = "DingShenFuObj";
            objPrefab = GameNetCtrlXK.GetInstance().DingShenFuNetPrefab;
            break;

        case DaoJuState.HuanWeiFu:
            type      = "HuanWeiFuObj";
            objPrefab = GameNetCtrlXK.GetInstance().HuanWeiFuNetPrefab;
            break;

        case DaoJuState.HuanYingFu:
            type      = "HuanYingFuObj";
            objPrefab = GameNetCtrlXK.GetInstance().HuanYingFuNetPrefab;
            break;

        case DaoJuState.JuLiFu:
            type      = "JuLiFuObj";
            objPrefab = GameNetCtrlXK.GetInstance().JuLiFuNetPrefab;
            break;
        }
        DaoJuNetCtrl netScript = objPrefab.GetComponent <DaoJuNetCtrl>();

        if (netScript != null)
        {
            Debug.LogError(objPrefab.name + " should not add DaoJuNetCtrl component!");
            return;
        }

        GameObject spawnObj = (GameObject)Network.Instantiate(objPrefab, transform.position,
                                                              transform.rotation, GlobalData.NetWorkGroup);

        NpcHealthCtrl healthScript = spawnObj.GetComponent <NpcHealthCtrl>();

        healthScript.SetObjType(type);
    }
    IEnumerator CheckConnectToServer()
    {
        if (GlobalData.GetInstance().gameLeve != GameLeve.WaterwheelNet)
        {
            yield break;
        }

        while (true)
        {
            Debug.Log("***************loadedLevel " + Application.loadedLevel
                      + ", IsIntoPlayGame " + Toubi.GetInstance().IsIntoPlayGame);
            if (Application.loadedLevel == (int)GameLeve.WaterwheelNet)
            {
                break;
            }

            if (Application.loadedLevel == (int)GameLeve.Movie)
            {
                if (!Toubi.GetInstance().IsIntoPlayGame)
                {
                    Toubi.GetInstance().StartIntoGame();
                    Toubi.GetInstance().IsIntoPlayGame = true;
                }
                yield return(new WaitForSeconds(0.5f));
            }
        }

        GlobalData.GetInstance().RemoveNetworkRpc();
        int playerIndex = IndexSpawnClient;

        Debug.Log("CheckConnectToServer::playerIndex " + playerIndex);

        GameObject obj    = GameNetCtrlXK.GetInstance().PlayerObj[playerIndex];
        Transform  tran   = GameNetCtrlXK.GetInstance().PlayerPos[playerIndex].transform;
        GameObject player = (GameObject)Network.Instantiate(obj, tran.position, tran.rotation, GlobalData.NetWorkGroup);
        WaterwheelPlayerNetCtrl playerScript = player.GetComponent <WaterwheelPlayerNetCtrl>();

        //playerScript.SetPlayerNetworkPlayer(playerNet);
        playerScript.SetIsHandlePlayer();

        //GameNetCtrlXK.GetInstance().SetPlayerList(player, playerIndex);

        Spawner.SpawnerScript.SpawnNetObj();
    }
    void MoveAiPlayerToEndPos()
    {
        Vector3 endPos = Vector3.zero;

        for (int i = 0; i < 7; i++)
        {
            if (GameNetCtrlXK.GetInstance().AiPlayerEndPos[i].activeSelf)
            {
                GameNetCtrlXK.GetInstance().AiPlayerEndPos[i].SetActive(false);
                endPos = GameNetCtrlXK.GetInstance().AiPlayerEndPos[i].transform.position;
                break;
            }
        }

        Vector3[] posArray = new Vector3[2];
        posArray[0] = PlayerTran.position;
        posArray[1] = endPos;
        iTween.MoveTo(PlayerObj, iTween.Hash("speed", AimMarkSpeed,
                                             "orienttopath", true,
                                             "easeType", iTween.EaseType.linear,
                                             "path", posArray,
                                             "oncomplete", "OnAiMoveToEndPos"));
    }