示例#1
0
    private float _cooldown; // Normalized

    public Cooldown(GameContext context, CooldownData data, Entity entity, Gear item)
    {
        _data   = data;
        Entity  = entity;
        Item    = item;
        Context = context;
    }
    // Update is called once per frame
    void Update()
    {
        GameObject   cooldownDataObject = GameObject.Find("CooldownDataObject");
        CooldownData cdData             = cooldownDataObject.GetComponent <CooldownData>();

//		if (Input.GetKeyDown ("[4]") & cdData.abilityObjectCooldown<=0 & delay<=0||(Input.GetAxis("LeftJoystickX4")<0&Input.GetButtonDown("A4")&cdData.abilityObjectCooldown<=0&delay<=0))
        if (Input.GetKeyDown("[4]") & cdData.abilityObjectCooldown <= 0 & delay <= 0 || (Input.GetAxis("RightJoystickX4") < -0.75 && cdData.abilityObjectCooldown <= 0 & delay <= 0))
        {
            SpawnAbilityObjects();
            audio.PlayOneShot(click);
            cdTrigger = true;
            delay     = 2f;
        }

        if (delay > 0)
        {
            delay -= Time.deltaTime;
        }

        if (cdTrigger & delay <= 0)
        {
            cdData.abilityObjectCooldown = 7;
            cdTrigger = false;
        }
    }
    // Use this for initialization
    void Start()
    {
        cooldownDataObject = GameObject.Find("CooldownDataObject");
        cdData             = cooldownDataObject.GetComponent <CooldownData> ();

        cdData.player1Cooldown = 0;

        hitEffectFab = (GameObject)Resources.Load("Prefabs/HitFlashFab", typeof(GameObject));
        skullFab     = (GameObject)Resources.Load("Prefabs/skullFab", typeof(GameObject));

        //deadFab = (GameObject)Resources.Load("Prefabs/foxDead", typeof(GameObject));
        //print ("start");
        count = 0;
        //SetCountText();
//		aSources = GetComponents<AudioSource>();
//		if (aSources != null) {
//			speedUP = aSources [0];
//			hit = aSources [1];
//		} else {
//			print ("audio not found "+gameObject.name);
//		}
//		aSources[0].Play();

        animator = GetComponentInChildren <Animator>();
    }
示例#4
0
        public async Task Jump(IUser target)
        {
            UserData d = GetUserData(Context.Message.Author.Id);

            if (d.HasCooldown(Cooldown.Steal))
            {
                CooldownData cd = d.cooldowns[Cooldown.Steal];
                await QuickEmbed($"You have to wait {cd.remainingTime} before stealing again!");

                return;
            }

            d.AddCooldown(Cooldown.Steal, configs.steal_cooldown);

            UserData t = GetUserData(target.Id);

            if (rnd.Next(0, 100) <= configs.steal_success_percentage) //successful
            {
                int stealamount = (int)(t.cash * configs.steal_money_percentage / 100f);

                d.cash += stealamount;
                t.cash -= stealamount;

                users[Context.Message.Author.Id] = d; //didn't use method because this is used twice
                users[target.Id] = t;

                SaveUserDataToJson();
                await QuickEmbed($"{Context.Message.Author.Mention} just stole **${stealamount}** from {target.Mention}!");

                return;
            }
            SaveUserDataToJson();

            await QuickEmbed($"{Context.Message.Author.Mention} has been caught stealing from {target.Mention}!");
        }
示例#5
0
 partial void initData()
 {
     BountyData.init();
     HuntData.init();
     HuntData.restartHunts();
     CooldownData.init();
 }
示例#6
0
 public void Save()
 {
     try {
         SaveKits();
         CooldownData.Save();
     } catch (Exception ex) {
         UEssentials.Logger.LogError("An error ocurred while saving kits...");
         UEssentials.Logger.LogError(ex.ToString());
     }
 }
示例#7
0
 public void Load()
 {
     try {
         LoadKits();
         CooldownData.Load();
     } catch (Exception ex) {
         UEssentials.Logger.LogError("An error ocurred while loading kits...");
         UEssentials.Logger.LogError(ex.ToString());
     }
 }
示例#8
0
 public void Save()
 {
     Console.WriteLine("kits saved");
     try {
         SaveKits();
         CooldownData.Save();
     } catch (Exception ex) {
         UEssentials.Logger.LogError("An error ocurred while saving kits...");
         UEssentials.Logger.LogException(ex);
     }
 }
示例#9
0
        private static CooldownData UpdateCooldownData(int snoId, int storageKey, int startTime, ActorAttributeType startAttr, int endTime, ActorAttributeType endAttr)
        {
            // Attribute time returned (game time) is not the same as ZetaDia.Globals.GameTick and the difference between the two vary over time.
            // When the buff starts a comparison to CurrentTime is recorded. This can then be used to work out know how much time has elapsed.
            // Offset will count down until it reaches EndOffset, then it has ended.

            Action <CooldownData> updateBuffDataObject = d =>
            {
                d.SnoId            = snoId;
                d.StartGameTime    = startTime;
                d.StartAttribute   = startAttr;
                d.EndGameTime      = endTime;
                d.EndAttribute     = endAttr;
                d.StorageKey       = storageKey;
                d.DurationGameTime = endTime - startTime;
                d.EndCurrentTime   = ZetaDia.Globals.GameTick + d.DurationGameTime;
                d.EndOffset        = (startTime - ZetaDia.Globals.GameTick) - d.DurationGameTime;
            };

            CooldownGroup group;
            CooldownData  data;

            if (!CooldownStore.ContainsKey(snoId))
            {
                group = new CooldownGroup();
                CooldownStore.Add(snoId, group);
            }
            else
            {
                group = CooldownStore[snoId];
            }

            var cooldowns = group.Cooldowns;

            if (!cooldowns.ContainsKey(storageKey))
            {
                data = new CooldownData();
                updateBuffDataObject(data);
                cooldowns.Add(storageKey, data);
            }
            else
            {
                data = cooldowns[storageKey];
                if (data.StartGameTime != startTime)
                {
                    updateBuffDataObject(data);
                }
            }

            data.Offset = startTime - ZetaDia.Globals.GameTick;
            //data.IsFinished = data.Offset <= data.EndOffset;
            return(data);
        }
示例#10
0
        /// <summary>
        /// Creates a new instance.
        /// </summary>
        /// <param name="character"></param>
        /// <param name="skillId"></param>
        /// <param name="level"></param>
        public Skill(Character character, SkillId skillId, int level)
        {
            this.Character    = character;
            this.Id           = skillId;
            this.Level        = level;
            this.Data         = ChannelServer.Instance.Data.SkillDb.Find(skillId) ?? throw new ArgumentException($"Unknown skill '{skillId}'.");
            this.CooldownData = ChannelServer.Instance.Data.CooldownDb.Find(this.Data.CooldownGroup) ?? throw new ArgumentException($"Unknown skill '{skillId}' cooldown group '{this.Data.CooldownGroup}'.");
            this.OverheatData = ChannelServer.Instance.Data.CooldownDb.Find(this.Data.OverheatGroup) ?? throw new ArgumentException($"Unknown skill '{skillId}' overheat group '{this.Data.OverheatGroup}'.");

            // I don't know what exactly LevelByDB's purpose is, but if
            // it's not sent, skills can be leveled past their max level.
            // It's like that's the value the client uses to calculate
            // the current max level.

            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.Level, () => this.Level));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.LevelByDB, () => this.Level));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SpendSP, () => this.SpendSp));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.WaveLength, () => this.Data.WaveLength));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SplAngle, () => this.Data.SplashAngle));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SplRange, () => this.Data.SplashRange));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SR, () => this.Data.SplashRate));

            // This property's value is the result of a Lua function,
            // see skill.ies. Does the item's SR (SCR_Get_Skl_SR) count
            // towards this as well?
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SkillSR, () => this.Data.SplashRate + this.Character.Properties.GetFloat(PropertyId.PC.SR)));

            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.MaxR, () => this.Data.MaxRange));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.CoolDown, () => this.Data.Cooldown));
            //this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SpendItemCount, () => 1f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.WaveLength, () => this.Data.WaveLength));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SkillFactor, () => this.Data.SkillFactor));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.HitDelay, () => this.Data.HitDelay));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SpendSta, () => 0f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.AbleShootRotate, () => 0f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SklSpdRate, () => 1f));             // Constant
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SpendPoison, () => 0f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.ReadyTime, () => 0f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SkillAtkAdd, () => 0f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.EnableShootMove, () => this.Data.EnableCastMove ? 1f : 0f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.UseOverHeat, () => this.Data.Overheat));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SkillASPD, () => 1f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.BackHitRange, () => 0f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.Skill_Delay, () => 0f));
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.ReinforceAtk, () => 0f));

            //this.Properties.Add(new RefFloatProperty(PropertyId.Skill.SkillSR, () => 14f)); // Has to be calculated with Lua Script
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.CaptionTime, () => 0f));             // Needs to be calculated if used, uses lua script
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.CaptionRatio, () => 0f));            // Needs to be calculated if used, uses lua script
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.CaptionRatio2, () => 0f));           // Needs to be calculated if used, uses lua script
            this.Properties.Add(new RefFloatProperty(PropertyId.Skill.CaptionRatio3, () => 0f));           // Needs to be calculated if used, uses lua script
        }
示例#11
0
 public static void load()
 {
     try
     {
         instance = CooldownDataFile.ReadObject <CooldownData>();
     }
     catch (Exception E)
     {
         StringBuilder sb = new StringBuilder($"loading {typeof(CooldownData).Name} failed. Make sure that all classes you're saving have a default constructor!\n");
         sb.Append(E.Message);
         PluginInstance.Puts(sb.ToString());
     }
 }
示例#12
0
        internal KitManager()
        {
            CooldownData = new CooldownData();
            KitMap       = new Dictionary <string, Kit>();
            KitData      = new KitData();

            var webResources = UEssentials.Core.WebResources;

            if (webResources.Loaded.ContainsKey("Kits"))
            {
                File.WriteAllText(Data.KitData.DataFilePath, webResources.Loaded["Kits"]);
            }
        }
示例#13
0
        /// <summary>
        /// Initializes the data files from the disk
        /// </summary>
        public void InitializeDataFiles()
        {
            // Load the lookup files
            EventPoints    = new EventPointTable();
            Settings       = new SettingsTable();
            Statistics     = new StatisticsTable();
            CustomCommands = new CustomCommandsTable();
            Rules          = new RuleTable();
            Mutes          = new MuteTable();
            Bans           = new BanTable();

            UnityDocs = new UnityDocs("manualReference.json", "scriptReference.json");
            Cooldowns = CooldownData.FromPath("cooldowns.json");
        }
示例#14
0
        void OnPlayerDisconnected(BasePlayer player, string reason)
        {
            if (player == null)
            {
                return;
            }
            Hunt hunt = HuntData.getHuntByHunter(player);

            if (hunt == null)
            {
                return;
            }
            hunt.end();
            CooldownData.removeCooldown(hunt.target);
        }
示例#15
0
文件: hunt.cs 项目: kiloOhm/Bounty
            public void end(BasePlayer winner = null)
            {
#if DEBUG
                PluginInstance.PrintToChat($"ending hunt {hunterName} -> {bounty.targetName}, winner: {winner?.displayName ?? "null"}");
#endif
                if (huntTimer != null)
                {
                    huntTimer.Destroy();
                }
                if (ticker != null)
                {
                    ticker.Destroy();
                }

                PluginInstance.rename(hunter, hunterName);

                if (winner == hunter)
                {
                    Interface.Oxide.CallHook("OnBountyCompleted", winner, target);
                    //msg
                    PluginInstance.huntSuccessfullMsg(this);

                    //payout
                    hunter.GiveItem(bounty.reward);
                }
                else if (winner == target)
                {
                    //msg
                    PluginInstance.huntFailedMsg(this);

                    //payout
                    target.GiveItem(bounty.reward);
                }
                else
                {
                    //msg
                    PluginInstance.huntExpiredMsg(this);
                    bounty.noteUid = bounty.giveNote(hunter);
                    BountyData.AddBounty(bounty);
                }
                PluginInstance.closeIndicators(target);
                PluginInstance.closeIndicators(hunter);
                bounty.hunt = null;
                HuntData.removeHunt(this);
                CooldownData.addCooldown(target);
            }
    // Use this for initialization
    void Start()
    {
        cooldownDataObject = GameObject.Find("CooldownDataObject");
        cdData             = cooldownDataObject.GetComponent <CooldownData> ();

        cdData.player3Cooldown = 0;
        hitEffectFab           = (GameObject)Resources.Load("Prefabs/HitFlashFab", typeof(GameObject));
        skullFab = (GameObject)Resources.Load("Prefabs/skullFab", typeof(GameObject));

        //deadFab = (GameObject)Resources.Load("Prefabs/bearDead", typeof(GameObject));
        count = 0;
//			SetCountText();
//		AudioSource[] aSources = GetComponents<AudioSource>();
//		speedUP = aSources[0];
//		hit = aSources[1];

        animator = GetComponentInChildren <Animator>();
    }
    // Update is called once per frame
    void Update()
    {
        GameObject   cooldownDataObject = GameObject.Find("CooldownDataObject");
        CooldownData cdData             = cooldownDataObject.GetComponent <CooldownData>();

//		if (Input.GetKeyDown("[0]")&&cdData.rainCooldown<=0||(Input.GetButtonDown("Y4")&cdData.rainCooldown<=0))
        if (Input.GetKeyDown("[0]") && cdData.rainCooldown <= 0 || (Input.GetButtonDown("B4") & cdData.rainCooldown <= 0))
        {
            rainSpawnTrigger = true;
        }

        if (rainSpawnTrigger == true)
        {
            audio.Play();
            StartCoroutine(Rain());

            rainSpawnTrigger    = false;
            cdData.rainCooldown = 30f;
        }
    }
示例#18
0
    // Update is called once per frame
    void Update()

    {
        GameObject   cooldownDataObject = GameObject.Find("CooldownDataObject");
        CooldownData cdData             = cooldownDataObject.GetComponent <CooldownData>();

        ///////speed up control

//		if (Input.GetKey ("[3]") & cdData.speedUpCooldown<=0||(Input.GetAxis("LeftJoystickX4")>0&Input.GetButtonDown("X4")&cdData.speedUpCooldown<=0))
        if (Input.GetKey("[3]") & cdData.speedUpCooldown <= 0 || (Input.GetAxis("LeftJoystickX4") > 0.75f & cdData.speedUpCooldown <= 0))
        {
            audio.PlayOneShot(click);

            speedUpKeydown = true;
            CoolD          = true;

            ;
        }
        if (CoolD == true & timeCD > 0)
        {
            timeCD -= Time.deltaTime;
        }

        if (speedUpKeydown == true & speedUpDuration > 0)
        {
            speedUpTrigger3 = true;

            speedUpDuration -= Time.deltaTime;

            cdData.speedUpCooldown = 7.0f;
        }


        else if (speedUpDuration <= 0)
        {
            speedUpTrigger3 = false;
            speedUpDuration = 3;
            speedUpKeydown  = false;
        }
    }
    void OnGUI()
    {
        GameObject   cooldownDataObject = GameObject.Find("CooldownDataObject");
        CooldownData cdData             = cooldownDataObject.GetComponent <CooldownData> ();

        //only display the CD when cooldown start counting
        if (cdData.player1Cooldown > 0)
        {
            GUI.skin = customSkin;
            GUI.Label(new Rect(100, 90, 200, 200), "CD: " + cdData.player1Cooldown.ToString("F0"));
            GUI.skin = null;
        }

        if (cdData.player2Cooldown > 0)
        {
            GUI.skin = customSkin;
            GUI.Box(new Rect(Screen.width / 2 - 100, 90, 100, 20), "CD: " + cdData.player2Cooldown.ToString("F0"));
            GUI.skin = null;
        }

        //other ui such as score and avator should place here
    }
    // Update is called once per frame
    void Update()
    {
        GameObject   cooldownDataObject = GameObject.Find("CooldownDataObject");
        CooldownData cdData             = cooldownDataObject.GetComponent <CooldownData>();


//		if (Input.GetKey ("[9]") & cdData.cannonCooldown3<=0||(Input.GetAxis("LeftJoystickY4")<0&Input.GetButtonDown("B4")&cdData.cannonCooldown3<=0))
        if (Input.GetKey("[9]") & cdData.cannonCooldown3 <= 0 || (Input.GetButtonDown("A4") && cdData.cannonCooldown3 <= 0))
        {
            SpawnCannonBall();
            audio.PlayOneShot(fire);
            cdData.cannonCooldown3 = 10.0f;

            CoolD = true;

            //OnGUI ();
        }
        if (CoolD == true & timeCD > 0)
        {
            timeCD -= Time.deltaTime;
        }
    }
示例#21
0
 internal KitManager()
 {
     CooldownData = new CooldownData();
     KitMap       = new Dictionary <string, Kit>();
     KitData      = UEssentials.Config.WebKits.Enabled ? new WebKitData() : new KitData();
 }
示例#22
0
文件: gui.cs 项目: kiloOhm/Bounty
        public void huntButton(BasePlayer player, Bounty bounty, huntErrorType error = huntErrorType.none)
        {
            GuiContainer c         = new GuiContainer(this, "huntButton", "bountyPreview");
            Rectangle    ButtonPos = new Rectangle(710, 856, 500, 100, resX, resY, true);

            List <GuiText> textOptions = new List <GuiText>
            {
                new GuiText("Start Hunting", guiCreator.getFontsizeByFramesize(13, ButtonPos), lightGreen),
                new GuiText("You are already hunting", guiCreator.getFontsizeByFramesize(23, ButtonPos), lightRed),
                new GuiText("Target is already being hunted", guiCreator.getFontsizeByFramesize(30, ButtonPos), lightRed),
                new GuiText("Target can't be hunted yet", guiCreator.getFontsizeByFramesize(26, ButtonPos), lightRed),
                new GuiText("Hunt Active", guiCreator.getFontsizeByFramesize(11, ButtonPos), lightRed),
                new GuiText("You can't hunt yourself!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed),
                new GuiText("Target is offline", guiCreator.getFontsizeByFramesize(17, ButtonPos), lightRed),
                new GuiText("Too close to the target!", guiCreator.getFontsizeByFramesize(24, ButtonPos), lightRed),
            };

            Action <BasePlayer, string[]> cb = (p, a) =>
            {
                TimeSpan targetCooldown   = TimeSpan.Zero;
                TimeSpan creationCooldown = new TimeSpan(0, 0, config.creationCooldown - (int)bounty.timeSinceCreation.TotalSeconds);
                if (error == huntErrorType.huntActive)
                {
                    return;
                }
                else if (bounty.target == null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.offline);
                }
                else if (bounty.target.IsSleeping())
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.offline);
                }
                else if (bounty.hunt != null || HuntData.getHuntByHunter(p) != null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.hunterAlreadyHunting);
                }
                else if (HuntData.getHuntByTarget(bounty.target) != null)
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.targetAlreadyHunted);
                }
                else if ((bounty.timeSinceCreation.TotalSeconds < config.creationCooldown || CooldownData.isOnCooldown(bounty.target, out targetCooldown)) && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.targetCooldown);
                    TimeSpan select = creationCooldown;
                    if (targetCooldown > creationCooldown)
                    {
                        select = targetCooldown;
                    }
                    player.ChatMessage($"Cooldown: {select.ToString(@"hh\:mm\:ss")}");
                }
                else if (bounty.target == player && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.selfHunt);
                }
                else if (Vector3.Distance(player.transform.position, bounty.target.transform.position) < config.safeDistance && !hasPermission(player, permissions.admin))
                {
                    Effect.server.Run(errorSound, player.transform.position);
                    huntButton(player, bounty, huntErrorType.tooClose);
                }
                else
                {
                    Effect.server.Run(successSound, player.transform.position);
                    bounty.startHunt(p);
                    BountyData.removeBounty(bounty.noteUid);
                    player.GetActiveItem()?.Remove();
                    closeBounty(player);
                }
            };

            c.addPlainButton("button", ButtonPos, GuiContainer.Layer.hud, (error == huntErrorType.none)?darkGreen:darkRed, FadeIn, FadeOut, textOptions[(int)error], cb, blur: GuiContainer.Blur.medium);
            c.display(player);

            if (error != huntErrorType.none && error != huntErrorType.huntActive)
            {
                PluginInstance.timer.Once(2f, () =>
                {
                    if (GuiTracker.getGuiTracker(player).getContainer(this, "bountyPreview") != null)
                    {
                        huntButton(player, bounty);
                    }
                });
            }
        }
示例#23
0
 public Cooldown(CooldownData data, EquippedItem item) : base(data, item)
 {
     _data = data;
 }
示例#24
0
 public Cooldown(CooldownData data, ConsumableItemEffect item) : base(data, item)
 {
     _data = data;
 }