public void OnPointerExit(PointerEventData eventData)
 {
     if (!UnityTools.IsPointerOverUI())
     {
         DoDisplayCursor(false);
     }
 }
Esempio n. 2
0
    public void StartUseSkill(Skill skill, string axis = null)
    {
        if (axis != null)
        {
            joystickColdTime = skill.parameters.TryGet("CD");
            //playerInfo.CurrentState = PlayerInfo.State.UseSkill;
            playerInfo.ToUseSkill = true;
            Vector2 v2 = UnityTools.ParseVector2(axis);
            direction = new Vector3(v2.x, 0, v2.y);

            if (playerInfo.anim.GetCurrentAnimatorStateInfo(0).IsName("Grounded") && IsTurnDone())
            {
                UseSkill(skill);
                playerInfo.ToUseSkill = false;
                return;
            }
        }
        else
        {
            UseSkill(skill);
            direction = Vector3.zero;
            return;
        }
        currentSkill = skill;
    }
Esempio n. 3
0
    public override void Init()
    {
        base.Init();

        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTools.FindChild(canvas, "CampInfoUI");

        mCampIcon         = UITools.FindChild <Image>(mRootUI, "CampIcon");
        mCampName         = UITools.FindChild <Text>(mRootUI, "CampName");
        mCampLevel        = UITools.FindChild <Text>(mRootUI, "CampLv");
        mWeaponLevel      = UITools.FindChild <Text>(mRootUI, "WeaponLv");
        mUpgradeCampBtn   = UITools.FindChild <Button>(mRootUI, "CampUpgradeBtn");
        mUpgradeWeaponBtn = UITools.FindChild <Button>(mRootUI, "WeaponUpgradeBtn");
        mTrainBtn         = UITools.FindChild <Button>(mRootUI, "TrainBtn");
        mCancelTrainBtn   = UITools.FindChild <Button>(mRootUI, "CancelTrainBtn");
        mAliveCount       = UITools.FindChild <Text>(mRootUI, "AliveCount");
        mTrainningCount   = UITools.FindChild <Text>(mRootUI, "TrainningCount");
        mTrainTime        = UITools.FindChild <Text>(mRootUI, "TrainTime");
        mTrainBtnText     = UITools.FindChild <Text>(mRootUI, "TrainBtnText");


        mTrainBtn.onClick.AddListener(OnTrainClick);
        mCancelTrainBtn.onClick.AddListener(OnCancelTrainClick);
        mUpgradeCampBtn.onClick.AddListener(OnCampUpgradeClick);
        mUpgradeWeaponBtn.onClick.AddListener(OnWeaponUpgradeClick);

        Hide();
    }
    public void Init()
    {
        this.m_oDicAllStringData.Clear();
        XmlDocument doc = XmlResAdapter.GetXmlDocument(UnityTools.LoadFileText(SystemConfig.StringPath));

        OnLoadStringFinishedEventHandler(doc);
    }
Esempio n. 5
0
 private void OnLoadFinishEventHandler(XmlDocument xmlDoc)
 {
     if (null != xmlDoc)
     {
         try
         {
             XmlNode xmlNode = xmlDoc.SelectSingleNode("config");
             foreach (XmlNode xmlNode2 in xmlNode.ChildNodes)
             {
                 XmlElement xmlElement = (XmlElement)xmlNode2;
                 string     attribute  = xmlElement.GetAttribute("texture");
                 string     attribute2 = xmlElement.GetAttribute("hotspot");
                 bool       bSoft      = false;
                 if (xmlElement.HasAttribute("soft"))
                 {
                     bSoft = xmlElement.GetAttribute("soft").Equals("true", StringComparison.InvariantCultureIgnoreCase);
                 }
                 Vector2     hotspot = UnityTools.String2Vector2(attribute2);
                 SCursorItem value   = new SCursorItem(attribute, hotspot, bSoft);
                 this.m_dicCursorItem.Add(value.Texture, value);
             }
         }
         catch (Exception ex)
         {
             this.m_log.Fatal(ex.ToString());
         }
     }
 }
Esempio n. 6
0
        //Called by a BaseInputModule when a drag is ended.
        public virtual void OnEndDrag(PointerEventData eventData)
        {
            RaycastHit hit;

            if (!UnityTools.IsPointerOverUI() && Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                if (Container.CanDropItems)
                {
                    DropItem();
                }
                else if (Container.UseReferences && Container.CanDragOut)
                {
                    Container.RemoveItem(Index);
                }
            }

            dragObject = null;

            if (this.m_ParentScrollRect != null)
            {
                this.m_ParentScrollRect.OnEndDrag(eventData);
            }
            //Repaint the slot
            Repaint();
        }
Esempio n. 7
0
    bool TryTrigger(GameEvent evt)
    {
        //直接触发
        if (!IsNoEvent(evt.m_EnterEventId))
        {
            ExecuteLuaEvent(evt.m_EnterEventId);
            return(true);
        }

        //既没有交互事件,也不是使用道具事件的情况
        if (IsNoEvent(evt.m_InteractiveEventId) && IsNoEvent(evt.m_UseItemEventId))
        {
            return(false);
        }

        if (evt.m_EventTargets == null || evt.m_EventTargets.Length == 0)
        {
            return(false);
        }

        //显示交互面板
        ShowInteractUIPanel(evt);

        UnityTools.HighLightObjects(evt.m_EventTargets, Color.red);

        return(true);
    }
        private IEnumerator CraftItem(Item item)
        {
            this.m_ProgressDuration = item.CraftingDuration;
            this.m_ProgressInitTime = Time.time;
            yield return(new WaitForSeconds(item.CraftingDuration));

            Item craftedItem = Instantiate(item);

            craftedItem.PropertyPercentRange = item.PropertyPercentRange;
            craftedItem.RandomizeProperties();
            craftedItem.Stack = 1;
            if (this.m_ResultStorageContainer.StackOrAdd(craftedItem))
            {
                for (int i = 0; i < item.ingredients.Count; i++)
                {
                    this.m_RequiredIngredientsContainer.RemoveItem(item.ingredients[i].item, item.ingredients[i].amount);
                }
                InventoryManager.Notifications.craftedItem.Show(UnityTools.ColorString(craftedItem.Name, craftedItem.Rarity.Color));
                ExecuteEvent <ITriggerCraftItem>(Execute, craftedItem);
            }
            else
            {
                InventoryManager.Notifications.containerFull.Show(this.m_ResultStorageContainer.Name);
                ExecuteEvent <ITriggerFailedToCraftItem>(Execute, item, FailureCause.ContainerFull);
                StopCrafting(item);
            }
        }
Esempio n. 9
0
 private void SendMoveNetMessage()
 {
     if (timerSvc.GetNowTime() - lastSendMoveTime > frameRate)
     {
         Vector3 pos = UnityTools.RoundTwo(gameObject.transform.position);
         Vector3 rot = UnityTools.RoundTwo(camTrans.localEulerAngles);
         if (lastPos == pos && lastRot == rot && BattleSys.Instance.GetPlayerAniState() != AniState.Fall)
         {
             return;
         }
         GameMsg gameMsg = new GameMsg
         {
             cmd         = (int)CMD.ReqSyncMove,
             reqSyncMove = new ReqSyncMove
             {
                 pos = new MyVector3
                 {
                     x = pos.x,
                     y = pos.y,
                     z = pos.z,
                 },
                 rot = new MyVector3
                 {
                     x = rot.x,
                     y = rot.y,
                     z = rot.z,
                 },
             }
         };
         netSvc.SendMsg(gameMsg);
         lastSendMoveTime = timerSvc.GetNowTime();
         lastPos          = pos;
         lastRot          = rot;
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 攻击客户端怪物
        /// </summary>
        /// <param name="hitActionId"></param>
        /// <param name="beasts"></param>
        private void AttackBeast(int hitActionId, List <uint> beasts)
        {
            //受伤者列表
            Dictionary <uint, List <int> > wounded = new Dictionary <uint, List <int> >();

            for (int i = 0; i < beasts.Count; i++)
            {
                List <int> harm = new List <int>();
                if (!GameWorld.Entities.ContainsKey(beasts[i]))
                {
                    continue;
                }
                EntityParent e = GameWorld.Entities[beasts[i]];
                //如果怪物不能被击中或者已经死亡
                if (UnityTools.BitFlag(e.StateFlag, StateCfg.NO_HIT_STATE) == 1 || UnityTools.BitFlag(e.StateFlag, StateCfg.DEATH_STATE) == 1)
                {
                    continue;
                }
                harm = CalculateDamage.CacuDamage(hitActionId, theOwner.ID, beasts[i]);
                wounded.Add(beasts[i], harm);
                uint demage = 0;
                demage   = e.CurHp < harm[1] ? e.CurHp : (uint)harm[1];
                e.CurHp -= demage;
            }
        }
Esempio n. 11
0
    /// <summary>
    /// 直接加载这个窗口
    /// </summary>
    /// <param name="path">Path.</param>
    public static void DirectShowPrefab(string path)
    {
        GameObject prefab   = Resources.Load(path) as GameObject;
        GameObject uicamera = GameObject.Find("UI Root/Camera");

        prefab = UnityTools.AddChild(uicamera, prefab);
    }
Esempio n. 12
0
    /// <summary>
    /// 检测网络状况并对照版本信息是否一致
    /// </summary>
    /// <param name="AsynResult">版本信息是否一致的处理委托</param>
    /// <param name="OnError">错误处理委托</param>
    public void BeforeCheck(Action <bool> AsynResult, Action OnError)
    {
        CheckTimeout checkTimeout = new CheckTimeout();

        checkTimeout.AsynIsNetworkTimeout((success) =>
        {
            //如果网络良好,开始下载服务器版本xml
            if (success)
            {
                DownloadMgr.Instance.AsynDownLoadHtml(SystemConfig.GetCfgInfoUrlByName("version"),
                                                      (serverVersion) =>
                {
                    //如果本地存在服务端的版本信息文本,覆盖下载的服务器文本
                    if (File.Exists(SystemConfig.ServerVersionPath))
                    {
                        serverVersion = UnityTools.LoadFileText(SystemConfig.ServerVersionPath);
                    }
                    //将文本转换成版本信息类
                    ServerVersion        = GetVersionInXml(serverVersion);
                    bool programVersion  = ServerVersion.ProgramVersionCodeInfo.Compare(LocalVersion.ProgramVersionCodeInfo) > 0;
                    bool resourceVersion = ServerVersion.ResourceVersionCodeInfo.Compare(LocalVersion.ResourceVersionCodeInfo) > 0;
                    //执行是否更新的委托
                    AsynResult(programVersion || resourceVersion);
                }, OnError);
            }
            else
            {
                if (OnError != null)
                {
                    OnError();
                }
            }
        });
    }
 /// <summary>
 /// 设置层级
 /// </summary>
 /// <param name="nLayer"></param>
 public void SetLayer(int nLayer)
 {
     if (null != this.m_cacheTransform)
     {
         UnityTools.SetLayerRecursively(this.m_cacheTransform.gameObject, nLayer);
     }
 }
Esempio n. 14
0
    public void RecieveData(string data)
    {
        if (clientManager.currentPlayer != this.gameObject)
        {
            return;
        }


        //对位置同步消息的接收
        if (data.Contains("*"))
        {
            Debug.Log("接收位置同步消息");
            //获取到其他控制器的数据信息并进行解析
            string[] strs = data.Split('*');
            pos      = UnityTools.ParseVector3(strs[0]);
            rotation = UnityTools.ParseVector3(strs[1]);
            tempFlag = strs[2];
        }
        else if (data.Contains("|"))//对子弹生成的消息进行接收
        {
            Debug.Log("接收子弹生成消息");
            bulletRequest.HandleResopnse(data);
        }
        else if (data.Contains("Player"))//对角色死亡消息进行接收
        {
            Debug.Log("接收死亡消息");
            RemoteDestroyPlayer(data);
        }
    }
Esempio n. 15
0
    void AttackTo(BaseHero from, BaseHero hero)
    {
        from.ReduceMP(expend);
        hero.ReduceHP(attackHP);
        UnityTools.Log(from.name + " 使用 " + name + " 攻击 " + hero.name + " 造成 " + attackHP + " 点伤害,眩晕" + dizzDuration + "毫秒,消耗 " + expend + "点MP");

        HeroAction treatAction = new HeroAction();

        treatAction.action = HeroActionType.Skill;
        SkillAction skillAction = new SkillAction();

        skillAction.action = SkillActionType.MiniMP;
        skillAction.args   = new object[] { expend };
        treatAction.args   = new object[] { from, hero, this, skillAction };
        from.AddAction(treatAction);

        HeroAction treatAction1 = new HeroAction();

        treatAction1.action = HeroActionType.Skill;
        SkillAction skillAction1 = new SkillAction();

        skillAction1.action = SkillActionType.MiniHP;
        skillAction1.args   = new object[] { attackHP };
        treatAction1.args   = new object[] { from, hero, this, skillAction1 };
        hero.AddAction(treatAction1);

        Buff buff = new Buff();

        buff.type     = BuffType.Dizzy;
        buff.start    = now;
        buff.duration = dizzDuration;
        hero.AddBuff(buff);
    }
        // Token: 0x06002D31 RID: 11569 RVA: 0x0013A4A8 File Offset: 0x001386A8
        public IMouseInputSource GetMouseInputSource(int playerId, int mouseIndex)
        {
            if (mouseIndex < 0)
            {
                throw new ArgumentOutOfRangeException("mouseIndex");
            }
            if (this.m_MouseInputSourcesList.Count == 0 && this.IsDefaultPlayer(playerId))
            {
                return(this.defaultMouseInputSource);
            }
            int count = this.m_MouseInputSourcesList.Count;
            int num   = 0;

            for (int i = 0; i < count; i++)
            {
                IMouseInputSource mouseInputSource = this.m_MouseInputSourcesList[i];
                if (!UnityTools.IsNullOrDestroyed <IMouseInputSource>(mouseInputSource) && mouseInputSource.playerId == playerId)
                {
                    if (mouseIndex == num)
                    {
                        return(mouseInputSource);
                    }
                    num++;
                }
            }
            return(null);
        }
Esempio n. 17
0
        protected IEnumerator DelayTooltip(float delay)
        {
            float time = 0.0f;

            yield return(true);

            while (time < delay)
            {
                time += Time.deltaTime;
                yield return(true);
            }
            if (InventoryManager.UI.tooltip != null && ObservedItem != null)
            {
                InventoryManager.UI.tooltip.Show(UnityTools.ColorString(ObservedItem.DisplayName, ObservedItem.Rarity.Color), ObservedItem.Description, ObservedItem.Icon, ObservedItem.GetPropertyInfo());
                if (InventoryManager.UI.sellPriceTooltip != null && ObservedItem.IsSellable && ObservedItem.SellPrice > 0)
                {
                    InventoryManager.UI.sellPriceTooltip.RemoveItems();
                    Currency currency = Instantiate(ObservedItem.SellCurrency);
                    currency.Stack = ObservedItem.SellPrice * ObservedItem.Stack;

                    InventoryManager.UI.sellPriceTooltip.StackOrAdd(currency);
                    InventoryManager.UI.sellPriceTooltip.Show();
                }
            }
        }
Esempio n. 18
0
    public override void Init()
    {
        base.Init();

        GameObject canvas = GameObject.Find("Canvas");

        mRootUI = UnityTools.FindChild(canvas, "GameStateUI");

        GameObject heart1 = UnityTools.FindChild(mRootUI, "Heart1");
        GameObject heart2 = UnityTools.FindChild(mRootUI, "Heart1");
        GameObject heart3 = UnityTools.FindChild(mRootUI, "Heart2");

        mHearts = new List <GameObject>();
        mHearts.Add(heart1);
        mHearts.Add(heart2);
        mHearts.Add(heart3);
        mSoliderCount = UITools.FindChild <Text>(mRootUI, "SoldierCount");

        mEnemyCount   = UITools.FindChild <Text>(mRootUI, "EnemyCount");
        mCurrentStage = UITools.FindChild <Text>(mRootUI, "StageCounter");
        mPauseBtn     = UITools.FindChild <Button>(mRootUI, "PauseBtn");
        mGameOverUI   = UnityTools.FindChild(mRootUI, "GameOver");
        mBackMenuBtn  = UITools.FindChild <Button>(mRootUI, "BackMenuBtn");
        mMessage      = UITools.FindChild <Text>(mRootUI, "Message");
        mEnergySlider = UITools.FindChild <Slider>(mRootUI, "EnergySlider");
        mEnergyText   = UITools.FindChild <Text>(mRootUI, "EnergyText");

        mMessage.text = "";
        mGameOverUI.SetActive(false);
    }
Esempio n. 19
0
    /// <summary>
    /// Send a new RFC call to the specified target.
    /// </summary>

    static void SendRFC(uint objID, byte rfcID, string rfcName, Target target, bool reliable, params object[] objs)
    {
#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            return;
        }
#endif
        bool executeLocally = false;

        if (target == Target.Host && TNManager.isHosting)
        {
            // We're the host, and the packet should be going to the host -- just echo it locally
            executeLocally = true;
        }
        else if (TNManager.isInChannel)
        {
            // We want to echo UDP-based packets locally instead of having them bounce through the server
            if (!reliable)
            {
                if (target == Target.All)
                {
                    target         = Target.Others;
                    executeLocally = true;
                }
                else if (target == Target.AllSaved)
                {
                    target         = Target.OthersSaved;
                    executeLocally = true;
                }
            }

            byte         packetID = (byte)((int)Packet.ForwardToAll + (int)target);
            BinaryWriter writer   = TNManager.BeginSend(packetID);
            writer.Write(GetUID(objID, rfcID));
            if (rfcID == 0)
            {
                writer.Write(rfcName);
            }
            UnityTools.Write(writer, objs);
            TNManager.EndSend(reliable);
        }
        else if (!TNManager.isConnected && (target == Target.All || target == Target.AllSaved))
        {
            // Offline packet
            executeLocally = true;
        }

        if (executeLocally)
        {
            if (rfcID != 0)
            {
                TNObject.FindAndExecute(objID, rfcID, objs);
            }
            else
            {
                TNObject.FindAndExecute(objID, rfcName, objs);
            }
        }
    }
Esempio n. 20
0
        private float GetFieldWidth(FlowNode node)
        {
            float fieldWidth = 0f;

            foreach (Port port in node.InputPorts)
            {
                if (port.Connections.Count == 0)
                {
                    FieldInfo field = node.GetType().GetField(port.fieldName);

                    object value = field.GetValue(node);
                    float  x     = EditorGUIUtility.fieldWidth + 20f;
                    if (UnityTools.IsNumeric(value) || value is string)
                    {
                        Vector2 temp = EditorStyles.textField.CalcSize(new GUIContent(value.ToString()));
                        x = Mathf.Clamp(temp.x, 15f, float.MaxValue);
                    }

                    if (x > fieldWidth)
                    {
                        fieldWidth = x;
                    }
                }
            }
            return(fieldWidth);
        }
Esempio n. 21
0
    void AttackTo(BaseHero from, BaseHero hero)
    {
        from.ReduceHP(expend, true);
        hero.ReduceHP(attackHP);
        UnityTools.Log(from.name + " 使用 " + name + " 攻击 " + hero.name + " 造成 " + attackHP + " 点伤害,消耗 " + expend + "点血量");

        HeroAction treatAction = new HeroAction();

        treatAction.action = HeroActionType.Skill;
        SkillAction skillAction = new SkillAction();

        skillAction.action = SkillActionType.MiniHP;
        skillAction.args   = new object[] { expend };
        treatAction.args   = new object[] { from, hero, this, skillAction };
        from.AddAction(treatAction);

        HeroAction treatAction1 = new HeroAction();

        treatAction1.action = HeroActionType.Skill;
        SkillAction skillAction1 = new SkillAction();

        skillAction1.action = SkillActionType.MiniHP;
        skillAction1.args   = new object[] { attackHP };
        treatAction1.args   = new object[] { from, hero, this, skillAction1 };
        hero.AddAction(treatAction1);
    }
Esempio n. 22
0
        private void FixedUpdate()
        {
            this.m_Rigidbody.velocity = transform.forward * m_Speed;

            if (!this.m_FollowTarget)
            {
                return;
            }

            if (this.m_Target != null)
            {
                Vector3 targetPosition = UnityTools.GetBounds(this.m_Target.gameObject).center;
                if (this.m_TurnSpeed < 0f)
                {
                    transform.LookAt(targetPosition);
                }
                else
                {
                    Vector3 directionToTarget  = targetPosition - transform.position;
                    Vector3 currentDirection   = transform.forward;
                    Vector3 resultingDirection = Vector3.RotateTowards(currentDirection, directionToTarget, this.m_TurnSpeed * Mathf.Deg2Rad * Time.fixedDeltaTime, 1f);
                    transform.rotation = Quaternion.LookRotation(resultingDirection);
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        /// 收集挂载点信息
        /// </summary>
        /// <param name="rootRenderNode"></param>
        /// <returns></returns>
        public int GatherRenderNodeInfo(GameObject rootRenderNode)
        {
            if (null == rootRenderNode)
            {
                return(0);
            }
            List <Transform> lst = new List <Transform>();

            UnityTools.FindAllTransform(rootRenderNode.transform, lst);
            int count = 0;

            foreach (var t in lst)
            {
                this.renderNodeObjects[t.name] = t.gameObject;
                if (t.name == "dummy_left_weapon_at" || t.name == "dummy_right_weapon_at" ||
                    t.name == "dummy_left_shield_at")
                {
                    bindNodeTable[t.name] = t;
                }
                ++count;
            }
            bindNodeTable["self"]       = Transform;
            bindNodeTable["rendernode"] = rootRenderNode.transform;
            return(count);
        }
Esempio n. 24
0
    /// <summary>
    /// 加载服务配置
    /// </summary>
    /// <returns></returns>
    private static bool LoadCfgInfo()
    {
        string cfgStr = null;

        //如果存在持久路径,就直接加载文本
        if (File.Exists(CfgPath))
        {
            cfgStr = UnityTools.LoadFileText(CfgPath);
        }
        else
        {
            //从Resources从加载配置文本
            TextAsset cfgUrl = Resources.Load("Cfg") as TextAsset;
            if (cfgUrl)
            {
                //从网页上下载与服务端有关的所有配置xml字符串
                cfgStr = DownloadMgr.Instance.DownLoadHtml(cfgUrl.text);
            }
            else
            {
                cfgStr = null;
            }
        }
        //加载xml内容为列表类
        CfgInfoList = LoadXMLText <CfgInfo>(cfgStr);
        return(CfgInfoList != null && CfgInfoList.Count > 0 ? true : false);
    }
Esempio n. 25
0
    bool InitData()
    {
        bool res = true;

        switch (level)
        {
        case 1:
            expend = (Fix64)100;
            break;

        case 2:
            expend = (Fix64)150;
            break;

        case 3:
            expend = (Fix64)200;
            break;

        default:
            UnityTools.Log("技能等级异常 " + name + " level=" + level);
            res = false;
            break;
        }
        return(res);
    }
Esempio n. 26
0
    void AddGuest()
    {
        var randomSpawnPoint = UnityTools.GetRandomWithinBounds(new Bounds(guestContainer.transform.position, UnityTools.GetSymmetricalVector(danceFlorSize)));

        guestSpawner.SpawnGuests(1, guestContainer.transform, randomSpawnPoint);
        plannedNewGuests--;
    }
        public IMouseInputSource GetMouseInputSource(int playerId, int mouseIndex)
        {
            if (mouseIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(mouseIndex));
            }
            if (this.m_MouseInputSourcesList.Count == 0 && this.IsDefaultPlayer(playerId))
            {
                return(this.defaultMouseInputSource);
            }
            int count = this.m_MouseInputSourcesList.Count;
            int num   = 0;

            for (int index = 0; index < count; ++index)
            {
                IMouseInputSource mouseInputSources = this.m_MouseInputSourcesList[index];
                if (!UnityTools.IsNullOrDestroyed <IMouseInputSource>((M0)mouseInputSources) && mouseInputSources.get_playerId() == playerId)
                {
                    if (mouseIndex == num)
                    {
                        return(mouseInputSources);
                    }
                    ++num;
                }
            }
            return((IMouseInputSource)null);
        }
Esempio n. 28
0
    private void Awake()
    {
        UnityTools.Log("battleView Awake");

        for (int i = 0; i < friendHeroItems.Length; i++)
        {
            friendHeroItems[i] = new HeroItem();
            friendHeroItems[i].Init(transform.Find("friend/heros/" + (i + 1) + "/heroItem"));
        }

        for (int i = 0; i < enermyHeroItems.Length; i++)
        {
            enermyHeroItems[i] = new HeroItem();
            enermyHeroItems[i].Init(transform.Find("enermy/heros/" + (i + 1) + "/heroItem"));
        }

        for (int i = 0; i < headItems.Length; i++)
        {
            headItems[i] = new HeadItem();
            headItems[i].Init(transform.Find("heads/item" + (i + 1)));
        }

        selectItem         = transform.Find("selectItem").gameObject;
        selectItemNameText = selectItem.transform.Find("name").GetComponent <Text>();

        resultItem.Init(transform.Find("result"));
        resultItem.gameObject.SetOnClick(OnResultClick);
    }
Esempio n. 29
0
    /// <summary>
    /// Draw the list of known LAN servers.
    /// </summary>

    void DrawServerList(Rect rect)
    {
        GUI.color = new Color(1f, 1f, 1f, mAlpha * mAlpha * 0.5f);
        GUI.Box(UnityTools.PadRect(rect, 8f), "");
        GUI.color = new Color(1f, 1f, 1f, mAlpha * mAlpha);

        GUILayout.BeginArea(rect);
        {
            GUILayout.Label("LAN Server List", text);

            // List of discovered servers
            List <ServerList.Entry> list = TNLobbyClient.knownServers.list;

            // Server list example script automatically collects servers that have recently announced themselves
            for (int i = 0; i < list.size; ++i)
            {
                ServerList.Entry ent = list[i];

                if (GUILayout.Button(ent.externalAddress.ToString(), button))
                {
                    TNManager.Connect(ent.externalAddress, ent.internalAddress);
                    mMessage = "Connecting...";
                }
            }
        }
        GUILayout.EndArea();
        GUI.color = Color.white;
    }
Esempio n. 30
0
    public void Move()
    {
        if (LocalPlayer == null || LocalPlayer.RoleInstanceIdList.Count == 0)
        {
            return;
        }
        StringBuilder sb    = new StringBuilder();
        int           count = 0;

        foreach (var id in LocalPlayer.RoleInstanceIdList)
        {
            GameObject go = roleGameObjects.TryGet(id);
            if (go == null || !go.GetComponent <PlayerInfo>().anim.GetCurrentAnimatorStateInfo(0).IsName("Grounded") || go.GetComponent <PlayerInfo>().IsMove == false)
            {
                continue;
            }

            count++;
            sb.Append(id + "|" + UnityTools.PackVector3(go.transform.position) + "|" +
                      UnityTools.PackVector3(go.transform.eulerAngles) + "|" + go.GetComponent <PlayerInfo>().anim.GetFloat("Forward") + ":");
        }
        if (count == 0)
        {
            return;
        }
        sb.Remove(sb.Length - 1, 1);
        moveRequest.SendRequest(sb.ToString());
    }