コード例 #1
0
ファイル: World.cs プロジェクト: jei-W/duckFarm
    // 스크립트 실행 순서에서 항상 World가 먼저 실행되도록 설정하여야 한다.
    // 그래야 월드 타임이 올바르게, 모두에게 전달될 수 있다.
    void Update()
    {
        CurrentGameWorldTimeMS += (long)(Time.deltaTime * 1000.0f);

        //worldTimer.Update(시간);
        WorldTimer.GetInstance().Update(CurrentGameWorldTimeMS);
    }
コード例 #2
0
    private void Awake()
    {
        Instance = this;

        TimeScale  = 1;
        GlobalTime = StartTime;

        StartCoroutine(IncreaseTime());
    }
コード例 #3
0
ファイル: WorldTimer.cs プロジェクト: jei-W/duckFarm
    public static WorldTimer GetInstance()
    {
        if (_instance == null)
        {
            _instance = new WorldTimer();
        }

        return(_instance);
    }
コード例 #4
0
        private void Update()
        {
            if (currentMiniGame == null)
            {
                Player.GetComponent <LD.ControllerMotor>().canMove = true;
            }
            if (Score < 0)
            {
                Score = 0;
            }
            // Update timer
            WorldTimer.UpdateTimer(Time.deltaTime);
            City.GetComponent <AudioSource>().volume = GameOver ? 0 : 0.1f;

            if (Input.GetKeyDown(KeyCode.Escape))
            {
                Application.Quit();
            }
            // Play volcano explosion sound
            if (!Audio.isPlaying && WorldTimer.CurrentTime <= 10)
            {
                Audio.PlayOneShot(eruptionClip);
            }

            // If timer is complete, reset world
            if (WorldTimer.IsFinished)
            {
                GameOver = true;
                //ResetWorld();
            }

            // Activate a deed for a number of random NPCs
            if (CityGenerator.Generated && currentDeeds < maxDeeds)
            {
                if (cityGen != null)
                {
                    GameObject randomMiniGame = cityGen.data.minigames[Random.Range(0, cityGen.data.minigames.Count)];
                    // Check if its a collectable mini-game
                    if (randomMiniGame == cityGen.data.minigames[0])
                    {
                        randomMiniGame.GetComponent <MiniGame>().objectives[1].objectToCollect = cityGen.data.collectableObjects[Random.Range(0, cityGen.data.collectableObjects.Count)];
                        randomMiniGame.GetComponent <MiniGame>().objectives[1].numToCollect    = Random.Range(1, 7);
                    }
                    npcs[Random.Range(0, npcs.Count)].GenerateDeed(randomMiniGame);
                }
            }

            if (currentMiniGame != null)
            {
                ObjectiveText = currentMiniGame.activeObjective.goalText;
            }
            else
            {
                ObjectiveText = "Find a citizen<color=purple> in need </color>to start a <color=green>good deed</color>";
            }
        }
コード例 #5
0
ファイル: Mating.cs プロジェクト: jei-W/duckFarm
    public override void Exit()
    {
        if (matingTimer != 0)
        {
            WorldTimer.GetInstance().UnregisterTimer(matingTimer);
            matingTimer = 0;
        }

        owner.ResetCurrentHeat();
        owner.LastMatingTime = World.CurrentGameWorldTimeMS;
    }
コード例 #6
0
    void Start()
    {
        // 사운드
        AS_Audio      = this.gameObject.AddComponent <AudioSource>();
        AS_Audio.clip = this.AC_Sound[0];
        AS_Audio.loop = false;

        WorldTimer._instance = this;
        _MobCreate           = GetComponent <MobCreate>();
        StartCoroutine(DayTimer());
    }
コード例 #7
0
 void Awake()
 {
     instance = this;
     timer = GetComponent<WorldTimer>();
     noteRef = GetComponent<WorldNoteRef>();
     memory = GetComponent<Memory>();
     cardPool = GetComponent<CardPool>();
     triggerMgr = GetComponent<TriggerMgr>();
     cardCanvas = _cardCanvas;
     eventCanvas = _eventCanvas;
 }
コード例 #8
0
 // Use this for initialization
 void Awake()
 {
     gm        = GetComponent <GridMovement>();
     smu       = updater.GetComponent <SimultaneousUpdater>();
     wt        = updater.GetComponent <WorldTimer>();
     pcc       = GetComponent <PlayerCoinController>();
     wcm       = updater.GetComponent <CoinMultiplier>();
     gst       = GetComponentInChildren <GridSpriteTranslate>();
     anim      = body.GetComponent <Animator>();
     anim_head = head.GetComponent <Animator>();
     eac       = GetComponent <EntityAudioController>();
 }
コード例 #9
0
    void ChangeSleeping(string state)
    {
        if (currentState == state)
        {
            return;
        }

        currentState = state;
        if (state == "sleepGround")
        {
            Debug.Log($"{owner.ObjectID} 땅바닥에서 잔다!");
            ownerAgent.isStopped = true;

            //owner.Sleeping(currentState);
            hungerChangeValue  = 3f;
            fatigueChangeValue = -25f;

            //랜덤시간 타이머 등록
            if (wakeUpTimer != 0)
            {
                WorldTimer.GetInstance().UnregisterTimer(wakeUpTimer);
                wakeUpTimer = 0;
            }

            // 타이머가 계속 .. 생성되고 제거되고 있다.
            wakeUpTimer = WorldTimer.GetInstance().RegisterTimer(World.CurrentGameWorldTimeMS + (int)sleepTime, OnWakeUpCallback);
            Debug.Log($"{sleepTime} 있다가 일어날래!({World.CurrentGameWorldTimeMS})");
        }
        if (state == "sleepShelter")
        {
            Debug.Log($"{owner.ObjectID} 축사에서 잔다!");
            ownerAgent.isStopped = true;

            //owner.Sleeping(currentState);
            hungerChangeValue  = 0f;
            fatigueChangeValue = -50f;

            //랜덤시간 타이머 등록
            if (wakeUpTimer != 0)
            {
                WorldTimer.GetInstance().UnregisterTimer(wakeUpTimer);
                wakeUpTimer = 0;
            }

            // 타이머가 계속 .. 생성되고 제거되고 있다.
            wakeUpTimer = WorldTimer.GetInstance().RegisterTimer(World.CurrentGameWorldTimeMS + (int)sleepTime, OnWakeUpCallback);
            Debug.Log($"{sleepTime} 있다가 일어날래!({World.CurrentGameWorldTimeMS})");
        }
        else if (state == "goingToShelter")
        {
        }
    }
コード例 #10
0
ファイル: Main.cs プロジェクト: RichTeaMan/EcoSim
 private void setupSimulationToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (CreateWorld createWorld = new CreateWorld())
     {
         createWorld.ShowDialog();
         if (createWorld.StartSim)
         {
             WorldTimer.Start();
             WorldView.BeginDraw(createWorld.CreatedWorld);
             logicWorker.RunWorkerAsync();
         }
     }
 }
コード例 #11
0
    public override void Exit()
    {
        ////초기값으로 셋팅
        //hungerChangeValue = 10f;
        //fatigueChangeValue = 5f;
        currentState = "";

        //타이머 등록해제
        if (wakeUpTimer != 0)
        {
            WorldTimer.GetInstance().UnregisterTimer(wakeUpTimer);
            wakeUpTimer = 0;
        }
    }
コード例 #12
0
ファイル: Player.cs プロジェクト: ZetItUp/DungeonCrawler
        public override void Draw(SpriteBatch spriteBatch)
        {
            base.Draw(spriteBatch);
            DrawColor = WorldTimer.GetWorldColorTint();


            if (tarPositions.Count > 0)
            {
                for (int i = 0; i < tarPositions.Count; i++)
                {
                    Drawing.DrawRectangle(spriteBatch, new Rectangle((int)tarPositions.ElementAt(i).X, (int)tarPositions.ElementAt(i).Y, GameScreen.TileWidth / GameScreen.TileSizeMultiplier, GameScreen.TileHeight / GameScreen.TileSizeMultiplier), Color.Red);
                }
            }
        }
コード例 #13
0
        internal void Pong(int time, PongPacket pkt)
        {
            updateLastSeen++;

            if (Owner.Timers.Contains(PongDCTimer))
            {
                Owner.Timers.Remove(PongDCTimer);
            }

            Owner.Timers.Add(PongDCTimer = new WorldTimer(DC_THRESOLD, (w, t) =>
            {
                SendError("Lost connection to server.");
                Client.Disconnect();
            }));
        }
コード例 #14
0
    void AutoMakingFood()
    {
        if (!FoodIsFull())
        {
            Debug.Log("물고기 생김");
            ++CurrentFoodCapacity;
        }

        //일정시간마다 물고기 잡는 일이 없으면 등록한다
        if (World.GetInstance().IsJobEmpty(World.JobType.CatchFishingInPond))
        {
            Debug.Log($"{this.ObjectID} 물고기 잡자");
            World.GetInstance().RequestCatchFish(this);
        }
        _timerID = WorldTimer.GetInstance().RegisterTimer(World.CurrentGameWorldTimeMS + World.oneDay, TimerCallback);
    }
コード例 #15
0
ファイル: Mating.cs プロジェクト: jei-W/duckFarm
    public override void Enter(object extraData = null)
    {
        base.Enter(extraData);

        isReadyMakeEgg = false;
        partner        = World.GetInstance().FindCloseOppositeSexDuck(owner);
        ChangeMatingState("followingPartner");

        //타이머 등록 : 오리는 발정시 상대 오리를 3일 만 따라다닌다
        if (matingTimer != 0)
        {
            WorldTimer.GetInstance().UnregisterTimer(matingTimer);
            matingTimer = 0;
        }
        matingTimer = WorldTimer.GetInstance().RegisterTimer(World.CurrentGameWorldTimeMS + World.oneDay * 3, EscapeState);
    }
コード例 #16
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            int        remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
            int        perDmg       = (int)(remainingDmg * 1000 / eff.DurationMS);
            WorldTimer tmr          = null;
            int        x            = 0;

            tmr = new WorldTimer(100, (w, t) =>
            {
                if (enemy.Owner == null)
                {
                    return;
                }
                w.BroadcastPacket(new ShowEffectPacket()
                {
                    EffectType = EffectType.Dead,
                    TargetId   = enemy.Id,
                    Color      = new ARGB(0xffddff00)
                }, null);

                if (x % 10 == 0)
                {
                    int thisDmg;
                    if (remainingDmg < perDmg)
                    {
                        thisDmg = remainingDmg;
                    }
                    else
                    {
                        thisDmg = perDmg;
                    }

                    enemy.Damage(this, t, thisDmg, true);
                    remainingDmg -= thisDmg;
                    if (remainingDmg <= 0)
                    {
                        return;
                    }
                }
                x++;

                tmr.Reset();

                Manager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
            });
            Owner.Timers.Add(tmr);
        }
コード例 #17
0
        void PoisonEnemy(World world, Enemy enemy, ActivateEffect eff)
        {
            var remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
            var perDmg       = (remainingDmg * 1000) / eff.DurationMS;

            WorldTimer tmr = null;
            var        x   = 0;

            Func <World, RealmTime, bool> poisonTick = (w, t) =>
            {
                if (enemy.Owner == null || w == null)
                {
                    return(true);
                }

                /*w.BroadcastPacketConditional(new ShowEffect()
                 * {
                 *  EffectType = EffectType.Dead,
                 *  TargetObjectId = enemy.Id,
                 *  Color = new ARGB(0xffddff00)
                 * }, p => enemy.DistSqr(p) < RadiusSqr);*/

                if (x % 4 == 0) // make sure to change this if timer delay is changed
                {
                    var thisDmg = perDmg;
                    if (remainingDmg < thisDmg)
                    {
                        thisDmg = remainingDmg;
                    }

                    enemy.Damage(this, t, thisDmg, true);
                    remainingDmg -= thisDmg;
                    if (remainingDmg <= 0)
                    {
                        return(true);
                    }
                }
                x++;

                tmr.Reset();
                return(false);
            };

            tmr = new WorldTimer(250, poisonTick);
            world.Timers.Add(tmr);
        }
コード例 #18
0
ファイル: Hatchery.cs プロジェクト: jei-W/duckFarm
    //오브젝트(알)의 요청에 따라 들여보낸다
    //들어온 알의 부화 시간을 잰다(28일)
    public override void EnterObject(ObjectBase targetObject)
    {
        base.EnterObject(targetObject);
        var targetEgg = targetObject.GetComponent <Egg>();

        //알이 부화가 안되는 썩은알이라면 리턴
        if (!targetEgg.hatchable)
        {
            return;
        }

        long currentTime = World.CurrentGameWorldTimeMS;

        targetEgg.hatchStartTime = currentTime;
        //알이 들어왔으면 알 부화 타이머를 켠다
        WorldTimer.GetInstance().RegisterTimer(currentTime + (long)(targetEgg.remainingHatchTime * World.oneDay), ( long timerID ) => Hatch(targetObject.ObjectID));
    }
コード例 #19
0
        void HealingPlayersPoison(World world, Player player, ActivateEffect eff)
        {
            var remainingHeal = eff.TotalDamage;
            var perHeal       = eff.TotalDamage * 1000 / eff.DurationMS;

            WorldTimer tmr = null;
            var        x   = 0;

            Func <World, RealmTime, bool> healTick = (w, t) =>
            {
                if (player.Owner == null || w == null)
                {
                    return(true);
                }

                if (x % 4 == 0) // make sure to change this if timer delay is changed
                {
                    var thisHeal = perHeal;
                    if (remainingHeal < thisHeal)
                    {
                        thisHeal = remainingHeal;
                    }

                    List <Packet> pkts = new List <Packet>();

                    Player.ActivateHealHp(player, thisHeal, pkts);
                    w.BroadcastPackets(pkts, null);
                    remainingHeal -= thisHeal;
                    if (remainingHeal <= 0)
                    {
                        return(true);
                    }
                }
                x++;

                tmr.Reset();
                return(false);
            };

            tmr = new WorldTimer(250, healTick);
            world.Timers.Add(tmr);
        }
コード例 #20
0
ファイル: RecordingManager.cs プロジェクト: MTGTech/StudioV
    // Use this for initialization
    void Start()
    {
        _recordingPanel = GameObject.Find("RecordingPanel");
        _recordingPanel.SetActive(false);

        _recordedTime = _recordingPanel.transform.Find("RecordingTimer").GetComponent <Text>();
        _worldTimer   = GetComponent <WorldTimer>();

//        if (Process.GetProcessesByName("obs64").Length > 0 || Process.GetProcessesByName("obs32").Length > 0)
//        {
//            _obs = new OBSWebsocket();
//            connectOBS();
//            _obs.OnRecordingStateChange += onRecordingStateChange;
//        }
//        else
//        {
//            Debug.LogError("OBSWebsocket: OBS Studio is not running. Please start OBS.");
//        }
//
//
//        //Start obs recording when Unity start
//        if (_obs != null)
//            StartOBSRecording();
    }
コード例 #21
0
ファイル: Player.UseItem.cs プロジェクト: C453/OryxKingdom
        private void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            try
            {
                if (eff.ConditionEffect != null)
                    enemy.ApplyConditionEffect(new[]
                    {
                        new ConditionEffect
                        {
                            Effect = (ConditionEffectIndex) eff.ConditionEffect,
                            DurationMS = (int) eff.EffectDuration
                        }
                    });
                var remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
                var perDmg = remainingDmg * 1000 / eff.DurationMS;
                WorldTimer tmr = null;
                var x = 0;
                tmr = new WorldTimer(100, (w, t) =>
                {
                    if (enemy.Owner == null) return;
                    w.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.Dead,
                        TargetId = enemy.Id,
                        Color = new ARGB(0xffddff00)
                    }, null);

                    if (x % 10 == 0)
                    {
                        int thisDmg;
                        if (remainingDmg < perDmg) thisDmg = remainingDmg;
                        else thisDmg = perDmg;

                        enemy.Damage(this, t, thisDmg, true);
                        remainingDmg -= thisDmg;
                        if (remainingDmg <= 0) return;
                    }
                    x++;

                    tmr.Reset();

                    RealmManager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
                });
                Owner.Timers.Add(tmr);
            }
            catch
            {
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.Out.WriteLine("Crash halted - Poisons!");
                Console.ForegroundColor = ConsoleColor.White;
            }
        }
コード例 #22
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            int remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
            int perDmg = (int)(remainingDmg * 1000 / eff.DurationMS);
            WorldTimer tmr = null;
            int x = 0;
            tmr = new WorldTimer(100, (w, t) =>
            {
                if (enemy.Owner == null) return;
                w.BroadcastPacket(new ShowEffectPacket()
                {
                    EffectType = EffectType.Dead,
                    TargetId = enemy.Id,
                    Color = new ARGB(0xffddff00)
                }, null);

                if (x % 10 == 0)
                {
                    int thisDmg;
                    if (remainingDmg < perDmg) thisDmg = remainingDmg;
                    else thisDmg = perDmg;

                    enemy.Damage(this, t, thisDmg, true);
                    remainingDmg -= thisDmg;
                    if (remainingDmg <= 0) return;
                }
                x++;

                tmr.Reset();

                RealmManager.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
            });
            Owner.Timers.Add(tmr);
        }
コード例 #23
0
        public override void Init(World owner)
        {
            WorldInstance = owner;
            var rand = new Random();
            int x, y;

            do
            {
                x = rand.Next(0, owner.Map.Width);
                y = rand.Next(0, owner.Map.Height);
            } while (owner.Map[x, y].Region != TileRegion.Spawn);
            Move(x + 0.5f, y + 0.5f);
            _tiles = new byte[owner.Map.Width, owner.Map.Height];
            SetNewbiePeriod();
            base.Init(owner);

            if (Client?.Character?.Pet != null)
            {
                GivePet(Client.Character.Pet);
            }

            if (owner.Id == World.NEXUS_ID || owner.Name == "Vault")
            {
                Client.SendPacket(new GlobalNotificationPacket
                {
                    Type = 0,
                    Text = Client.Account.Gifts.Count > 0 ? "giftChestOccupied" : "giftChestEmpty"
                });
            }

            SendAccountList(Locked, AccountListPacket.LockedListId);
            SendAccountList(Ignored, AccountListPacket.IgnoredListId);

            WorldTimer[] accTimer = { null };
            owner.Timers.Add(accTimer[0] = new WorldTimer(5000, (w, t) =>
            {
                Manager.Database.DoActionAsync(db =>
                {
                    if (Client?.Account == null)
                    {
                        return;
                    }
                    Client.Account = db.GetAccount(AccountId, Manager.GameData);
                    Credits        = Client.Account.Credits;
                    CurrentFame    = Client.Account.Stats.Fame;
                    Tokens         = Client.Account.FortuneTokens;
                    accTimer[0].Reset();
                    Manager.Logic.AddPendingAction(_ => w.Timers.Add(accTimer[0]), PendingPriority.Creation);
                });
            }));

            WorldTimer[] pingTimer = { null };
            owner.Timers.Add(pingTimer[0] = new WorldTimer(PingPeriod, (w, t) =>
            {
                Client.SendPacket(new PingPacket {
                    Serial = _pingSerial++
                });
                pingTimer[0].Reset();
                Manager.Logic.AddPendingAction(_ => w.Timers.Add(pingTimer[0]), PendingPriority.Creation);
            }));
            Manager.Database.DoActionAsync(db =>
            {
                db.UpdateLastSeen(Client.Account.AccountId, Client.Character.CharacterId, owner.Name);
                db.LockAccount(Client.Account);
            });

            if (Client.Account.IsGuestAccount)
            {
                owner.Timers.Add(new WorldTimer(1000, (w, t) => Client.Disconnect(Client.DisconnectReason.REGISTRATION_NEEDED)));
                Client.SendPacket(new FailurePacket
                {
                    ErrorId          = 8,
                    ErrorDescription = "Registration needed."
                });
                Client.SendPacket(new PasswordPromtPacket
                {
                    CleanPasswordStatus = PasswordPromtPacket.Register
                });
                return;
            }
            CheckSetTypeSkin();
        }
コード例 #24
0
        private void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            try
            {
                if (eff.ConditionEffect != null)
                    enemy.ApplyConditionEffect(new[]
                    {
                        new ConditionEffect
                        {
                            Effect = (ConditionEffectIndex) eff.ConditionEffect,
                            DurationMS = (int) eff.EffectDuration
                        }
                    });
                int remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
                int perDmg = remainingDmg * 1000 / eff.DurationMS;
                WorldTimer tmr = null;
                int x = 0;
                tmr = new WorldTimer(100, (w, t) =>
                {
                    if (enemy.Owner == null) return;
                    w.BroadcastPacket(new ShowEffectPacket
                    {
                        EffectType = EffectType.Dead,
                        TargetId = enemy.Id,
                        Color = new ARGB(0xffddff00)
                    }, null);

                    if (x % 10 == 0)
                    {
                        int thisDmg;
                        if (remainingDmg < perDmg) thisDmg = remainingDmg;
                        else thisDmg = perDmg;

                        enemy.Damage(this, t, thisDmg, true);
                        remainingDmg -= thisDmg;
                        if (remainingDmg <= 0) return;
                    }
                    x++;

                    tmr.Reset();

                    Manager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
                });
                Owner.Timers.Add(tmr);
            }
            catch (Exception ex)
            {
                Entity.logger.Error(ex);
            }
        }
コード例 #25
0
        public override void Init(World owner)
        {
            WorldInstance = owner;
            var rand = new Random();
            int x, y;

            do
            {
                x = rand.Next(0, owner.Map.Width);
                y = rand.Next(0, owner.Map.Height);
            } while (owner.Map[x, y].Region != TileRegion.Spawn);
            Move(x + 0.5f, y + 0.5f);
            tiles = new byte[owner.Map.Width, owner.Map.Height];
            SetNewbiePeriod();
            base.Init(owner);

            if (owner.Id == World.NEXUS_ID || owner.Name == "Vault")
            {
                Client.SendPacket(new Global_NotificationPacket
                {
                    Type = 0,
                    Text = Client.Account.Gifts.Count > 0 ? "giftChestOccupied" : "giftChestEmpty"
                });
            }

            SendAccountList(Locked, AccountListPacket.LOCKED_LIST_ID);
            SendAccountList(Ignored, AccountListPacket.IGNORED_LIST_ID);

            WorldTimer[] accTimer = { null };
            owner.Timers.Add(accTimer[0] = new WorldTimer(5000, (w, t) =>
            {
                Manager.Database.DoActionAsync(db =>
                {
                    if (Client?.Account == null)
                    {
                        return;
                    }
                    Client.Account = db.GetAccount(AccountId, Manager.GameData);
                    Credits        = Client.Account.Credits;
                    CurrentFame    = Client.Account.Stats.Fame;
                    Tokens         = Client.Account.FortuneTokens;
                    accTimer[0].Reset();
                    Manager.Logic.AddPendingAction(_ => w.Timers.Add(accTimer[0]), PendingPriority.Creation);
                });
            }));

            WorldTimer[] pingTimer = { null };
            owner.Timers.Add(pingTimer[0] = new WorldTimer(PING_PERIOD, (w, t) =>
            {
                Client.SendPacket(new PingPacket {
                    Serial = pingSerial++
                });
                pingTimer[0].Reset();
                Manager.Logic.AddPendingAction(_ => w.Timers.Add(pingTimer[0]), PendingPriority.Creation);
            }));
            Manager.Database.DoActionAsync(db =>
            {
                db.UpdateLastSeen(Client.Account.AccountId, Client.Character.CharacterId, owner.Name);
            });

            if (!Client.Account.VerifiedEmail)
            {
                Client.SendPacket(new VerifyEmailDialogPacket());
                owner.Timers.Add(new WorldTimer(1000, (w, t) => Client.Disconnect()));
                return;
            }
            CheckSetTypeSkin();
        }
コード例 #26
0
ファイル: Player.UseItem.cs プロジェクト: ppmaks/LOE-V6-GAME
        private void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            try
            {
                if (eff.ConditionEffect != null)
                {
                    enemy?.ApplyConditionEffect(new[]
                    {
                        new ConditionEffect
                        {
                            Effect     = (ConditionEffectIndex)eff.ConditionEffect,
                            DurationMS = (int)eff.EffectDuration
                        }
                    });
                }
                int        remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
                int        perDmg       = remainingDmg * 1000 / eff.DurationMS;
                WorldTimer tmr          = null;
                int        x            = 0;
                tmr = new WorldTimer(100, (w, t) =>
                {
                    if (enemy.Owner == null)
                    {
                        return;
                    }
                    w.BroadcastPacket(new SHOWEFFECT
                    {
                        EffectType = EffectType.Poison,
                        TargetId   = enemy.Id,
                        Color      = new ARGB(0xffddff00)
                    }, null);

                    if (x % 10 == 0)
                    {
                        int thisDmg;
                        if (remainingDmg < perDmg)
                        {
                            thisDmg = remainingDmg;
                        }
                        else
                        {
                            thisDmg = perDmg;
                        }

                        enemy.Damage(this, t, thisDmg, true);
                        remainingDmg -= thisDmg;
                        if (remainingDmg <= 0)
                        {
                            return;
                        }
                    }
                    x++;

                    tmr.Reset();

                    Manager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
                });
                Owner?.Timers.Add(tmr);
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
コード例 #27
0
ファイル: HUD.cs プロジェクト: F1xx/Alien_Nation
 void UpdateTime()
 {
     TimePassed.text = WorldTimer.GetTimeAsFormattedString();
 }
コード例 #28
0
ファイル: Player.cs プロジェクト: patrick323/Skilly-Realmsv2
        public override void Init(World owner)
        {
            WorldInstance = owner;
            var rand = new Random();
            int x, y;

            do
            {
                x = rand.Next(0, owner.Map.Width);
                y = rand.Next(0, owner.Map.Height);
            } while (owner.Map[x, y].Region != TileRegion.Spawn);
            Move(x + 0.5f, y + 0.5f);
            tiles = new byte[owner.Map.Width, owner.Map.Height];
            SetNewbiePeriod();
            base.Init(owner);

            if (Client.Character.Pet != null)
            {
                GivePet(Client.Character.Pet);
            }


            SendAccountList(Locked, AccountListPacket.LOCKED_LIST_ID);
            SendAccountList(Ignored, AccountListPacket.IGNORED_LIST_ID);

            WorldTimer[] accTimer = { null };
            owner.Timers.Add(accTimer[0] = new WorldTimer(5000, (w, t) =>
            {
                Manager.Database.DoActionAsync(db =>
                {
                    if (Client?.Account == null)
                    {
                        return;
                    }
                    Client.Account = db.GetAccount(AccountId, Manager.GameData);
                    Credits        = Client.Account.Credits;
                    CurrentFame    = Client.Account.Stats.Fame;
                    Tokens         = Client.Account.FortuneTokens;
                    accTimer[0].Reset();
                    Manager.Logic.AddPendingAction(_ => w.Timers.Add(accTimer[0]), PendingPriority.Creation);
                });
            }));

            WorldTimer[] pingTimer = { null };
            owner.Timers.Add(pingTimer[0] = new WorldTimer(PING_PERIOD, (w, t) =>
            {
                Client.SendPacket(new PingPacket {
                    Serial = pingSerial++
                });
                pingTimer[0].Reset();
                Manager.Logic.AddPendingAction(_ => w.Timers.Add(pingTimer[0]), PendingPriority.Creation);
            }));
            Manager.Database.DoActionAsync(db =>
            {
                db.UpdateLastSeen(Client.Account.AccountId, Client.Character.CharacterId, owner.Name);
                db.LockAccount(Client.Account);
            });

            if (Client.Account.IsGuestAccount)
            {
                owner.Timers.Add(new WorldTimer(1000, (w, t) => Client.Disconnect()));
                Client.SendPacket(new networking.svrPackets.FailurePacket
                {
                    ErrorId          = 8,
                    ErrorDescription = "Registration needed."
                });
                Client.SendPacket(new PasswordPromtPacket
                {
                    CleanPasswordStatus = PasswordPromtPacket.REGISTER
                });
                return;
            }

            if (!Client.Account.VerifiedEmail && Program.Verify)
            {
                Client.SendPacket(new VerifyEmailDialogPacket());
                owner.Timers.Add(new WorldTimer(1000, (w, t) => Client.Disconnect()));
                return;
            }
            CheckSetTypeSkin();
        }
コード例 #29
0
 void Awake()
 {
     timer = world.GetComponent<WorldTimer>();
     listenerId = timer.dateTime.Listen(DateTimeListener);
 }
コード例 #30
0
        void PoisonEnemy(Enemy enemy, ActivateEffect eff)
        {
            try
            {
                if (eff.ConditionEffect != null)
                {
                    enemy.ApplyConditionEffect(new ConditionEffect[] {
                        new ConditionEffect()
                        {
                            Effect     = (ConditionEffectIndex)eff.ConditionEffect,
                            DurationMS = (int)eff.EffectDuration
                        }
                    });
                }
                int        remainingDmg = (int)StatsManager.GetDefenseDamage(enemy, eff.TotalDamage, enemy.ObjectDesc.Defense);
                int        perDmg       = (int)(remainingDmg * 1000 / eff.DurationMS);
                WorldTimer tmr          = null;
                int        x            = 0;
                tmr = new WorldTimer(100, (w, t) =>
                {
                    if (enemy.Owner == null)
                    {
                        return;
                    }
                    w.BroadcastPacket(new ShowEffectPacket()
                    {
                        EffectType = EffectType.Dead,
                        TargetId   = enemy.Id,
                        Color      = new ARGB(0xffddff00)
                    }, null);

                    if (x % 10 == 0)
                    {
                        int thisDmg;
                        if (remainingDmg < perDmg)
                        {
                            thisDmg = remainingDmg;
                        }
                        else
                        {
                            thisDmg = perDmg;
                        }

                        enemy.Damage(this, t, thisDmg, true);
                        remainingDmg -= thisDmg;
                        if (remainingDmg <= 0)
                        {
                            return;
                        }
                    }
                    x++;

                    tmr.Reset();

                    RealmManager.Logic.AddPendingAction(_ => w.Timers.Add(tmr), PendingPriority.Creation);
                });
                Owner.Timers.Add(tmr); //Disabling this causes poisons to do nothing. However, this line causes problems :/
            }
            catch
            {
                Console.ForegroundColor = ConsoleColor.DarkBlue;
                Console.Out.WriteLine("Warning! Poison Lag!");
                Console.ForegroundColor = ConsoleColor.White;
            }
        }