Ejemplo n.º 1
0
    void SwitchGunCallBack(params object[] obj_arr)
    {
        int id = (int)obj_arr[0];

        if (id == RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID)
        {
            gun1Use.SetActive(true);
            gun2Use.SetActive(false);
        }
        else if (id == RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID)
        {
            gun1Use.SetActive(false);
            gun2Use.SetActive(true);
        }
    }
Ejemplo n.º 2
0
    public override void Open()
    {
        gunTxt.Clear();
        gunIm.Clear();
        base.Open();
        foreach (var item in playerDic.Keys)
        {
            Destroy(playerDic[item]);
        }
        playerDic.Clear();
        foreach (var item in RoomSingle.GetInfos().Keys)
        {
            if (NetworkTools.GetLocalIP().Equals(item))
            {
                continue;//忽略自己
            }
            GameObject obj = Instantiate <GameObject>(playerPrefab, playerParent.transform);
            obj.SetActive(true);
            obj.transform.localScale = Vector3.one;
            BattlePlayerUI bpui = obj.GetComponent <BattlePlayerUI>();
            bpui.UpdatePanel(item, 1, 1);//初始让其满血
            playerDic.Add(item, bpui);
        }

        gunIm.Add(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID, gun1Image);
        gunIm.Add(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID, gun2Image);
        gunTxt.Add(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID, gun1Text);
        gunTxt.Add(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID, gun2Text);

        gun1Image.sprite = Resources.Load <Sprite>("UI/WeaponIcon/Gun" + RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID);
        gun2Image.sprite = Resources.Load <Sprite>("UI/WeaponIcon/Gun" + RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID);

        GunRow g1Row = GunModel_S.Instance.GetGunInfo(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID);

        UpdateGunMessage(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID, g1Row.Cartridge, g1Row.CarryCap);
        GunRow g2Row = GunModel_S.Instance.GetGunInfo(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID);

        UpdateGunMessage(RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID, g2Row.Cartridge, g2Row.CarryCap);

        hpImage.fillAmount = 1;
        gun1Use.SetActive(true);
        gun2Use.SetActive(false);
        EventCenterManager._Instance.AddListener(EventType.UpdatePlayerUI, UpdatePlayerMsgCallBack);
        EventCenterManager._Instance.AddListener(EventType.UpdateBattleGunUI, UpdateGunMsgCallBack);
        EventCenterManager._Instance.AddListener(EventType.SwitchGun, SwitchGunCallBack);
        EventCenterManager._Instance.AddListener(EventType.OpenAimed, OpenAniedCallBack);
    }
Ejemplo n.º 3
0
    void Awake()
    {
        Instance = this;
        UIManager._Instance.OpenWindow(WindowName.Battle);
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        playerDic.Add(NetworkTools.GetLocalIP(), player.GetComponent <PlayerBase>());
        foreach (string item in RoomSingle.GetInfos().Keys)
        {
            if (!item.Equals(NetworkTools.GetLocalIP()))
            {
                PlayerInfoMessage m = RoomSingle.GetInfos()[item];
                InstancePlayerAI(item, m.ID, m.gun1ID, m.gun2ID);
            }
        }

        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible   = false;
    }
Ejemplo n.º 4
0
 // Use this for initialization
 void Awake()
 {
     if (isTest)
     {
         NetworkManager._Instance.StartBattleServer(ips);
         return;
     }
     //判断自己是不是房主
     if (RoomSingle.roomIP.Equals(NetworkTools.GetLocalIP()))
     {
         Debug.Log("启动战斗服务器");
         ips = new string[RoomSingle.GetInfos().Count];
         int i = 0;
         foreach (var item in RoomSingle.GetInfos().Keys)
         {
             ips[i] = item;
             i++;
         }
         NetworkManager._Instance.StartBattleServer(ips);
     }
 }
Ejemplo n.º 5
0
    // Use this for initialization
    void Start()
    {
        guns = new GunBase[2];
        GameObject gun1 = Instantiate <GameObject>(Resources.Load <GameObject>("Prefab/Gun/Gun_" + RoomSingle.GetInfos()[ib.IP].gun1ID + "_AI"));

        guns[0] = gun1.GetComponent <GunBase>();
        GameObject gun2 = Instantiate <GameObject>(Resources.Load <GameObject>("Prefab/Gun/Gun_" + RoomSingle.GetInfos()[ib.IP].gun2ID + "_AI"));

        guns[1] = gun2.GetComponent <GunBase>();
        base.BaseStart();
    }
Ejemplo n.º 6
0
    // Use this for initialization
    void Start()
    {
        guns = new GunBase[2];
        GameObject gun1 = Instantiate <GameObject>(Resources.Load <GameObject>("Prefab/Gun/Gun_" + RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun1ID));

        guns[0] = gun1.GetComponent <GunBase>();
        GameObject gun2 = Instantiate <GameObject>(Resources.Load <GameObject>("Prefab/Gun/Gun_" + RoomSingle.GetInfos()[NetworkTools.GetLocalIP()].gun2ID));

        guns[1] = gun2.GetComponent <GunBase>();

        base.BaseStart();
        myRotation.y         = transform.rotation.eulerAngles.y;
        watchPointRotation.x = watchPoint.rotation.eulerAngles.x;
        watchPointRotation.y = watchPoint.rotation.eulerAngles.y;
        gunAngle             = watchPointRotation.x;
        Cursor.visible       = false;                 //控制鼠标显示和隐藏, true显示, false时隐藏
        Cursor.lockState     = CursorLockMode.Locked; //把鼠标锁定在窗口内,防止鼠标拖到边缘是显示

        for (int i = 0; i < guns.Length; i++)
        {
            guns[i].SetPhysicGunPos(physicGunPos, myCamera, watchPoint);
        }
        currentGun.InitSight();
    }