コード例 #1
0
        public override void Damage(int dmg, object src)
        {
            base.Damage(dmg, src);

            if (!IsAlive || _enraged || HP >= HT / 4)
            {
                return;
            }

            _enraged = true;
            Spend(Tick);

            if (!Dungeon.Visible[pos])
            {
                return;
            }

            GLog.Warning(TxtEnraged, Name);
            Sprite.ShowStatus(CharSprite.Negative, "enraged");
        }
コード例 #2
0
 private void DispatchCheckSocketState()
 {
     if (_currDispatchSocketState == _currSocketState || _luaCallback == null)
     {
         return;
     }
     try
     {
         if (GLog.IsLogWarningEnabled)
         {
             GLog.LogWarning("socket DispatchCheckSocketState 派发事件 currDispatchSocketState :[" + _currDispatchSocketState + "]  _currSocketState :" + _currSocketState);
         }
         _currDispatchSocketState = _currSocketState;
         _luaCallback((int)_currSocketState);
     }
     catch (Exception e)
     {
         GLog.LogException("DispatchCheckSocketState ==> " + e.Message);
     }
 }
コード例 #3
0
ファイル: WndSadGhost.cs プロジェクト: zvinch/SharpDungeon
        private void SelectReward(Ghost ghost, Item item, Item reward)
        {
            Hide();

            item.Detach(Dungeon.Hero.Belongings.Backpack);

            if (reward.DoPickUp(Dungeon.Hero))
            {
                GLog.Information(Hero.TxtYouNowHave, reward.Name);
            }
            else
            {
                Dungeon.Level.Drop(reward, ghost.pos).Sprite.Drop();
            }

            ghost.Yell("Farewell, adventurer!");
            ghost.Die(null);

            Ghost.Quest.Complete();
        }
コード例 #4
0
ファイル: HttpManager.cs プロジェクト: ErrorMee/HexFrame
    IEnumerator OnLoadText(string url, Action <string> finishLoad)
    {
        UnityWebRequest uwr = new UnityWebRequest(url);

        uwr.downloadHandler = new DownloadHandlerBuffer();
        yield return(uwr.Send());

        if (uwr.isNetworkError || uwr.isHttpError)
        {
            GLog.Error(uwr.error);
        }
        else
        {
            if (finishLoad != null)
            {
                finishLoad(uwr.downloadHandler.text);
            }
        }
        uwr.Dispose();
    }
コード例 #5
0
        public void ScrollToPreviousGroup()
        {
            if (totalCount <= 0)
            {
                if (GLog.IsLogInfoEnabled)
                {
                    GLog.LogInfo("error element Count =" + totalCount);
                }
                return;
            }
            int pos = 0;

            pos = GetPageIndex();
            pos = pos - 1;

            if (isLoop || Mathf.Abs((int)contentTransform.anchoredPosition[directionAxisIndex]) > 0)
            {
                MoveOffset(pos);
            }
        }
コード例 #6
0
        private void TakeReward(Imp imp, DwarfToken tokens, Item reward)
        {
            Hide();

            tokens.DetachAll(Dungeon.Hero.Belongings.Backpack);

            reward.Identify();
            if (reward.DoPickUp(Dungeon.Hero))
            {
                GLog.Information(Hero.TxtYouNowHave, reward.Name);
            }
            else
            {
                Dungeon.Level.Drop(reward, imp.pos).Sprite.Drop();
            }

            imp.Flee();

            Imp.Quest.Complete();
        }
コード例 #7
0
ファイル: Scroll.cs プロジェクト: zvinch/SharpDungeon
 public override void Execute(Hero hero, string action)
 {
     if (action.Equals(AcRead))
     {
         if (hero.Buff <Blindness>() != null)
         {
             GLog.Warning(TxtBlinded);
         }
         else
         {
             CurUser = hero;
             curItem = Detach(hero.Belongings.Backpack);
             DoRead();
         }
     }
     else
     {
         base.Execute(hero, action);
     }
 }
コード例 #8
0
ファイル: PatchManager.cs プロジェクト: ErrorMee/GemaFrame
    private void LoadRemotePatchFiles()
    {
        GameEvent.SendEvent(GameEventType.GameFlow, GameFlow.PatchFileRemoteLoad);
        remotePatchFiles = new PatchFiles();
        string remotePatchFilesPath = PathUtil.RemotePatchFilesPath();

        GLog.Log("remotePatchFilesPath " + remotePatchFilesPath);
        if (File.Exists(remotePatchFilesPath))
        {
            HttpManager.Instance.LoadText(remotePatchFilesPath, (res) =>
            {
                remotePatchFiles.Load(res);
                CompareLocalAndRemotePatchFiles();
            });
        }
        else
        {
            GLog.Error(string.Format("{0} is null", remotePatchFilesPath), true);
        }
    }
コード例 #9
0
ファイル: WandOfAmok.cs プロジェクト: zvinch/SharpDungeon
        protected internal override void OnZap(int cell)
        {
            var ch = Actor.FindChar(cell);

            if (ch != null)
            {
                if (ch == Dungeon.Hero)
                {
                    Buff.Affect <Vertigo>(ch, Vertigo.Duration(ch));
                }
                else
                {
                    Buff.Affect <Amok>(ch, 3f + Level);
                }
            }
            else
            {
                GLog.Information("nothing happened");
            }
        }
コード例 #10
0
    void OnShareResultHandler(int reqID, ResponseState state, PlatformType type, Hashtable result)
    {
        if (state == ResponseState.Success)
        {
            GLog.Log("share successfully - share result :");
            GLog.Log(MiniJSON.jsonEncode(result));
        }
        else if (state == ResponseState.Fail)
        {
#if UNITY_ANDROID
            GLog.Log("share fail! throwable stack = " + result["stack"] + "; error msg = " + result["msg"]);
#elif UNITY_IPHONE
            GLog.Log("share fail! error code = " + result["error_code"] + "; error msg = " + result["error_msg"]);
#endif
        }
        else if (state == ResponseState.Cancel)
        {
            GLog.Log("share cancel !");
        }
    }
コード例 #11
0
 private void DispatchSendMsgBase()
 {
     if (_clientSocket == null || !_clientSocket.Connected || _sendDataCaching == null)
     {
         return;
     }
     try
     {
         SendDataCaching data;
         while (_sendDataCaching.Count > 0)
         {
             data = _sendDataCaching.Dequeue();
             SendMsgBase(data.protocallType, data.data);
         }
     }
     catch (Exception e)
     {
         GLog.LogException("DispatchSendMsgBase ==> " + e.Message);
     }
 }
コード例 #12
0
        private void CreateItem(int index)
        {
            ScorllItemData itemData;

            if (unUsedItemQueue.Count > 0)
            {
                itemData = unUsedItemQueue.Dequeue();
                ResetBaseItemData(index, itemData);
            }
            else
            {
                int adjustIndex = index;
                if (isLoop)
                {
                    adjustIndex = adjustIndex % totalCount;
                    if (adjustIndex < 0)
                    {
                        adjustIndex += totalCount;
                    }
                }
                var obj = CreateItemLuaFunc(adjustIndex);
                if (obj == null)
                {
                    if (GLog.IsLogErrorEnabled)
                    {
                        GLog.LogError("Expected to find obj of type gameObject,but found none" + obj);
                    }
                }
                itemData            = new ScorllItemData();
                itemData.index      = index;
                itemData.gameObject = obj;
                var rectTransf = itemData.gameObject.GetComponent <RectTransform>();
                rectTransf.SetParent(contentTransform, false);
                rectTransf.anchorMin        = new Vector2(0, 1);
                rectTransf.anchorMax        = new Vector2(0, 1);
                rectTransf.pivot            = new Vector2(0, 1);
                rectTransf.sizeDelta        = cellSize;
                rectTransf.anchoredPosition = GetPosition(index);
            }
            itemList.Add(itemData);
        }
コード例 #13
0
        internal static byte[] DicToBytes(Object arg)
        {
            try
            {
                Type        type      = arg.GetType();
                MethodInfo  enumrator = type.GetMethod("GetEnumerator", BindingFlags.Instance | BindingFlags.Public);
                object      objEnum   = enumrator.Invoke(arg, null);
                MethodInfo  moveNext  = objEnum.GetType().GetMethod("MoveNext", BindingFlags.Instance | BindingFlags.Public);
                List <byte> list      = new List <byte>();
                bool        gotNext   = (bool)moveNext.Invoke(objEnum, null);
                while (true)
                {
                    if (!gotNext)
                    {
                        break;
                    }

                    object current = objEnum.GetType().GetProperty("Current", BindingFlags.Instance | BindingFlags.Public).GetValue(objEnum, null);
                    object key     = current.GetType().GetProperty("Key", BindingFlags.Instance | BindingFlags.Public).GetValue(current, null);
                    object value   = current.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public).GetValue(current, null);

                    byte[] bufferKey = Serializer.GetBytes(key);
                    byte[] bufferVal = Serializer.GetBytes(value);
                    if (bufferKey == default(byte[]) || bufferVal == default(byte[]))
                    {
                        continue;
                    }
                    list.AddRange(bufferKey);
                    list.AddRange(bufferVal);

                    gotNext = (bool)moveNext.Invoke(objEnum, null);
                }
                list.InsertRange(0, list.Count.ToBytes());
                return(list.ToArray());
            }
            catch (Exception e)
            {
                GLog.LogError(e.ToString());
            }
            return(default(byte[]));
        }
コード例 #14
0
    public void SelectDefaultToggle(int tag)
    {
        m_cache_tag          = tag;
        isTriggerLuaListener = false;
        LuaTable lua = gameObject.GetComponent <LuaBehaviour>().lua;

        for (int i = 0; i < Toggles.Count; i++)
        {
            int        toggleTag = i + 1;
            GameObject obj       = Toggles[i];
            LuaTable   btnLua    = obj.GetComponent <LuaBehaviour>().lua;
            if (btnLua == null)
            {
                if (GLog.IsLogWarningEnabled)
                {
                    GLog.LogWarning("CommonToggle.SelectDefaultToggle: btnLua is null !!!");
                }
            }
            if (toggleTag == tag)
            {
                obj.GetComponent <Toggle>().isOn = true;
                if (onToggleSelected != null)
                {
                    onToggleSelected(lua, btnLua, tag);
                }
                if (onTagSwitched != null)
                {
                    onTagSwitched(lua, tag);
                }
            }
            else
            {
                obj.GetComponent <Toggle>().isOn = false;
                if (onToggleDeselected != null)
                {
                    onToggleDeselected(lua, btnLua, tag);
                }
            }
        }
        isTriggerLuaListener = true;
    }
コード例 #15
0
        public static string Capture()
        {
            //yield return new WaitForEndOfFrame();
            String       path = null;
            const String screenShotFileName = "share";

            try
            {
                int width  = Screen.width;
                int height = Screen.height;

                Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);

                tex.ReadPixels(new Rect(0, 0, width, height), 0, 0, true);
                tex.Apply();


                String dir = Application.persistentDataPath + "/" + "screenshot/";
                path = dir + screenShotFileName + ".png";

                var imagebytes = tex.EncodeToPNG();
                PlatExt.PlatDependant.CreateFolder(dir);
                PlatExt.PlatDependant.DeleteFile(path);
                using (var stream = PlatExt.PlatDependant.OpenWrite(path))
                {
                    stream.Write(imagebytes, 0, imagebytes.Length);
                }

                GameObject.DestroyImmediate(tex);
            }
            catch (System.Exception e)
            {
                if (GLog.IsLogInfoEnabled)
                {
                    GLog.LogInfo("ScreenCaptrueError:" + e);
                }
            }


            return(path);
        }
コード例 #16
0
        public static void CopyFile(this string src, string dst)
        {
            if (IsFileSameName(src, dst))
            {
                return;
            }

            if (!string.IsNullOrEmpty(src) && !string.IsNullOrEmpty(dst))
            {
                var srcs = OpenRead(src);
                if (srcs != null)
                {
                    try
                    {
                        using (var dsts = OpenWrite(dst))
                        {
                            CopyTo(srcs, dsts);
                        }
                    }
                    catch (Exception e)
                    {
                        if (GLog.IsLogErrorEnabled)
                        {
                            GLog.LogException(e);
                        }
                        throw;
                    }
                    finally
                    {
                        srcs.Dispose();
                    }
                }
                else
                {
                    if (GLog.IsLogInfoEnabled)
                    {
                        GLog.LogInfo(src + " cannot be read.");
                    }
                }
            }
        }
コード例 #17
0
 public static bool EnsureDirectory(string path)
 {
     try
     {
         path.Replace("\\", "/");
         if (path.Contains("."))
         {
             path = path.Substring(0, path.LastIndexOf("/") + 1);
         }
         if (!Directory.Exists(path))
         {
             Directory.CreateDirectory(path);
         }
         return(true);
     }
     catch (Exception e)
     {
         GLog.Error(e.ToString());
     }
     return(false);
 }
コード例 #18
0
ファイル: TomeOfMastery.cs プロジェクト: zvinch/SharpDungeon
        public virtual void Choose(HeroSubClass way)
        {
            Detach(CurUser.Belongings.Backpack);

            CurUser.Spend(TimeToRead);
            CurUser.Busy();

            CurUser.subClass = way;

            CurUser.Sprite.DoOperate(CurUser.pos);
            Sample.Instance.Play(Assets.SND_MASTERY);

            SpellSprite.Show(CurUser, SpellSprite.Mastery);
            CurUser.Sprite.Emitter().Burst(Speck.Factory(Speck.MASTERY), 12);
            GLog.Warning("You have chosen the way of the {0}!", Utils.Capitalize(way.Title));

            if (way == HeroSubClass.BERSERKER && CurUser.HP <= CurUser.HT * Fury.Level)
            {
                Buff.Affect <Fury>(CurUser);
            }
        }
コード例 #19
0
ファイル: Monk.cs プロジェクト: zvinch/SharpDungeon
        public override int AttackProc(Character enemy, int damage)
        {
            if (Random.Int(6) != 0 || enemy != Dungeon.Hero)
            {
                return(damage);
            }

            var hero   = Dungeon.Hero;
            var weapon = hero.Belongings.Weapon;

            if (weapon == null || weapon is Knuckles || weapon.cursed)
            {
                return(damage);
            }

            hero.Belongings.Weapon = null;
            Dungeon.Level.Drop(weapon, hero.pos).Sprite.Drop();
            GLog.Warning(TxtDisarm, Name, weapon.Name);

            return(damage);
        }
コード例 #20
0
        public override void Proc(Character attacker, Character defender, int damage)
        {
            if (enchantment != null)
            {
                enchantment.Proc(this, attacker, defender, damage);
            }

            if (levelKnown)
            {
                return;
            }

            if (--_hitsToKnow > 0)
            {
                return;
            }

            levelKnown = true;
            GLog.Information(TxtIdentify, Name, ToString());
            Badge.ValidateItemLevelAquired(this);
        }
コード例 #21
0
        public static void Apply(Weapon weapon, bool forSpeed)
        {
            weapon.Detach(weapon.CurUser.Belongings.Backpack);

            if (forSpeed)
            {
                weapon.imbue = Weapon.Imbue.Speed;
                GLog.Positive(TxtFast, weapon.Name);
            }
            else
            {
                weapon.imbue = Weapon.Imbue.Accuracy;
                GLog.Positive(TxtAccurate, weapon.Name);
            }

            weapon.CurUser.Sprite.DoOperate(weapon.CurUser.pos);
            Sample.Instance.Play(Assets.SND_MISS);

            weapon.CurUser.Spend(TimeToApply);
            weapon.CurUser.Busy();
        }
コード例 #22
0
        private void DownLoadManifest(Callback_0 onSuccess)
        {
            if (m_webAgent == null)
            {
                m_webAgent = new WebRequestAgent();
            }
            if (File.Exists(m_temPath + Config.BundleManifest))
            {
                File.Delete(m_temPath + Config.BundleManifest);
            }

            long length = m_webAgent.GetLength(m_remoteUrl + Config.BundleManifest);

            m_webAgent.onDownloadSuccess = onSuccess;
            m_webAgent.onDownloadFailed  = () =>
            {
                GLog.E("下载manifest失败,提示重试");
            };
            StartCoroutine(m_webAgent.Download(m_remoteUrl + Config.BundleManifest, m_temPath + Config.BundleManifest,
                                               length));
        }
コード例 #23
0
    public IEnumerator PlayAudio(string path, float volume, bool loop = false)
    {
        ClipVolume = volume;
        var clip = ResManager.LoadRes(path, typeof(AudioClip)) as AudioClip;

        if (clip)
        {
            audioSource.clip = clip;
            ApplyVolume();
            audioSource.Play();
            audioSource.loop = loop;
            yield return(new AudioPlayEndYieldInstruction(audioSource));
        }
        else
        {
            if (GLog.IsLogErrorEnabled)
            {
                GLog.LogError("Audio clip not found, path :" + path);
            }
        }
    }
コード例 #24
0
        protected internal object[] ResumeRaw(params object[] args)
        {
            if (_IsDone)
            {
                return(null);
            }
            if (args != null)
            {
                for (int i = 0; i < args.Length; ++i)
                {
                    L.PushLua(args[i]);
                }
            }
            int status = L.resume(args == null ? 0 : args.Length);

            if (status == lua.LUA_YIELD || status == 0)
            {
                object[] rv = ObjectPool.GetReturnValueFromPool(L.gettop());
                for (int i = 0; i < rv.Length; ++i)
                {
                    rv[i] = L.GetLua(i + 1);
                }
                if (status == 0)
                {
                    _IsDone = true;
                }
                return(rv);
            }
            else
            {
                L.pushcfunction(Capstones.LuaExt.LuaFramework.ClrDelErrorHandler);
                L.insert(-2);
                L.pcall(1, 1, 0);
                if (GLog.IsLogErrorEnabled)
                {
                    GLog.LogError(L.GetLua(-1).UnwrapDynamic());
                }
            }
            return(null);
        }
コード例 #25
0
ファイル: Blacksmith.cs プロジェクト: zvinch/SharpDungeon
        public void Upgrade(Item item1, Item item2)
        {
            Item first, second;

            if (item2.level > item1.level)
            {
                first  = item2;
                second = item1;
            }
            else
            {
                first  = item1;
                second = item2;
            }

            Sample.Instance.Play(Assets.SND_EVOKE);
            ScrollOfUpgrade.Upgrade(Dungeon.Hero);
            Item.Evoke(Dungeon.Hero);

            if (first.IsEquipped(Dungeon.Hero))
            {
                ((EquipableItem)first).DoUnequip(Dungeon.Hero, true);
            }

            first.Upgrade();
            GLog.Positive(TXT_LOOKS_BETTER, first.Name);
            Dungeon.Hero.SpendAndNext(2f);
            Badge.ValidateItemLevelAquired(first);

            if (second.IsEquipped(Dungeon.Hero))
            {
                ((EquipableItem)second).DoUnequip(Dungeon.Hero, false);
            }

            second.DetachAll(Dungeon.Hero.Belongings.Backpack);

            Quest.reforged = true;

            Journal.Remove(Journal.Feature.TROLL);
        }
コード例 #26
0
        protected internal override void OnZap(int cell)
        {
            var ch = Actor.FindChar(cell);

            if (ch == CurUser)
            {
                SetKnown();
                ScrollOfTeleportation.TeleportHero(CurUser);
            }
            else
            if (ch != null)
            {
                var count = 10;
                int pos;
                do
                {
                    pos = Dungeon.Level.RandomRespawnCell();
                    if (count-- <= 0)
                    {
                        break;
                    }
                } while (pos == -1);

                if (pos == -1)
                {
                    GLog.Warning(ScrollOfTeleportation.TxtNoTeleport);
                }
                else
                {
                    ch.pos = pos;
                    ch.Sprite.Place(ch.pos);
                    ch.Sprite.Visible = Dungeon.Visible[pos];
                    GLog.Information(CurUser.Name + " teleported " + ch.Name + " to somewhere");
                }
            }
            else
            {
                GLog.Information("nothing happened");
            }
        }
コード例 #27
0
        public override void Execute(Hero hero, string action)
        {
            base.Execute(hero, action);

            if (!action.Equals(AcEat))
            {
                return;
            }

            switch (pdsharp.utils.Random.Int(5))
            {
            case 0:
                GLog.Information("You see your hands turn invisible!");
                Buff.Affect <Invisibility>(hero, Invisibility.Duration);
                break;

            case 1:
                GLog.Information("You feel your skin hardens!");
                Buff.Affect <Barkskin>(hero).Level(hero.HT / 4);
                break;

            case 2:
                GLog.Information("Refreshing!");
                Buff.Detach <Poison>(hero);
                Buff.Detach <Cripple>(hero);
                Buff.Detach <Weakness>(hero);
                Buff.Detach <Bleeding>(hero);
                break;

            case 3:
                GLog.Information("You feel better!");
                if (hero.HP < hero.HT)
                {
                    hero.HP = Math.Min(hero.HP + hero.HT / 4, hero.HT);
                    hero.Sprite.Emitter().Burst(Speck.Factory(Speck.HEALING), 1);
                }
                break;
            }
        }
コード例 #28
0
 // 不改动原有版本 去掉元素滚动时边界判断
 public void ScrollToPageEx(int index) // 外部固定索引
 {
     if (totalCount <= 0)
     {
         if (GLog.IsLogInfoEnabled)
         {
             GLog.LogInfo("error element Count =" + totalCount);
         }
         return;
     }
     if (index >= 0 && index < totalCount)
     {
         var itemCount = itemList.Count;
         var pageIndex = index;
         for (int i = 0; i < itemCount; i++)
         {
             var item        = itemList[i];
             var adjustIndex = item.index;
             adjustIndex = adjustIndex % totalCount;
             if (adjustIndex < 0)
             {
                 adjustIndex += totalCount;
             }
             if (adjustIndex == index)
             {
                 pageIndex = item.index;
                 break;
             }
         }
         ScrollToInternalPageEx(pageIndex);
     }
     else
     {
         if (GLog.IsLogInfoEnabled)
         {
             GLog.LogInfo("input page error index =" + index + ",current pageTotalCount = " + totalCount);
         }
     }
 }
コード例 #29
0
        private void ScrollToInternalPage(int internalIndex)
        {
            if (totalCount <= 0)
            {
                if (GLog.IsLogInfoEnabled)
                {
                    GLog.LogInfo("error element Count =" + totalCount);
                }
                return;
            }
            internalIndex = Mathf.FloorToInt((float)internalIndex / maxPerLine);
            internalIndex = internalIndex - Mathf.RoundToInt((float)(internalIndex - currentInternalIndex) / totalCount) * totalCount;

            if (isLoop || Mathf.Abs(contentTransform.anchoredPosition[directionAxisIndex]) + Mathf.Abs(selfTransform.rect.size[directionAxisIndex]) < contentTransform.rect.size[directionAxisIndex])
            {
                MoveOffset(internalIndex);
            }
            else
            {
                currentPageIndex = internalIndex;
            }
        }
コード例 #30
0
 public void AddItem(int index)
 {
     if (isLoop) // 循环滚动增加容易造成数据混乱
     {
         return;
     }
     if (index > totalCount)
     {
         if (GLog.IsLogErrorEnabled)
         {
             GLog.LogError("add error:" + index);
         }
         return;
     }
     totalCount += 1;
     AddItemIntoPanel(index);
     if (isShowLine)
     {
         AddLine();
     }
     UpdateTotalWidthAndHeight();
 }