Exemplo n.º 1
0
    void Start()
    {
        // physics
        _curPos = transform.position;
        _newPos = transform.position;

        // camera
        cam = Camera.main;

        // script components
        mover = GetComponent <PlayerMovement>();

        // health and stats
        _xp        = 0;
        _maxHealth = _health = maxHealth;

        healthSlider = healthBar.GetComponent <Slider>();
        xpSlider     = xpBar.GetComponent <Slider>();

        healthSlider.value = 100;
        xpSlider.value     = 0;

        // ability cooldowns
        _punchCD = punchCD.GetComponent <CooldownController>();
        _kickCD  = kickCD.GetComponent <CooldownController>();

        _punchCD.cooldown = 1f / punchSpeed;
        _kickCD.cooldown  = 1f / kickSpeed;
    }
Exemplo n.º 2
0
    private void HandleAfkCommand(TwitchChatMessage chatMessage)
    {
        foreach (AfkCommandType type in AfkCommandTypes)
        {
            // ReSharper disable once ForeachCanBeConvertedToQueryUsingAnotherGetEnumerator
            foreach (string alias in AppSettings.CommandList[type].Alias)
            {
                Regex pattern = PatternCreator.Create(alias, chatMessage.Channel.Prefix, @"(\s|$)");

                // ReSharper disable once InvertIf
                if (pattern.IsMatch(chatMessage.Message))
                {
                    if (CooldownController.IsOnAfkCooldown(chatMessage.UserId))
                    {
                        return;
                    }

                    AfkCommandHandler.Handle(chatMessage, type);
                    CooldownController.AddAfkCooldown(chatMessage.UserId);
                    TwitchBot.CommandCount++;
                    return;
                }
            }
        }
    }
Exemplo n.º 3
0
    protected void dash(KeyCode button)
    {
        switch (button)
        {
        case KeyCode.D:
            rb.velocity = new Vector2(waveDashSpeed + moveSpeed, rb.velocity.y);
            break;

        case KeyCode.A:
            rb.velocity = new Vector2(-waveDashSpeed - moveSpeed, rb.velocity.y);
            break;

        case KeyCode.W:
            rb.velocity = new Vector2(rb.velocity.x, waveDashSpeed + moveSpeed);
            break;

        case KeyCode.S:
            rb.velocity = new Vector2(rb.velocity.x, -waveDashSpeed - moveSpeed);
            break;
        }
        CooldownController.Cooldown1();
        waveDashed            = true;
        addWaveSpeed          = waveDashSpeed;
        waveDashDurationTimer = waveDashDuration;
        waveDashDelayTimer    = waveDashDelay;
        anim.SetBool("dash", true);

        if (!grounded)
        {
            airWaveDashed = true;
        }
    }
Exemplo n.º 4
0
 // ecf005
 private MageRole() : base("mage",
                           new Color(236f / 255f, 240f / 255f, 5f / 255f, 1))
 {
     StoneficationCooldown = CreateCooldown("stonefication.cooldown");
     StoneficationEffect   = CreateCooldown("stonefication.effect");
     TranspositionCooldown = CreateCooldown("transposition.cooldown");
 }
Exemplo n.º 5
0
    protected override void Start()
    {
        playerEntity = Player.Instance.transform;

        cooldownShoot = new CooldownController(this, timeForShoot.TimeSpan);

        StartCoroutine(CheckTargetPosition(playerEntity));
    }
Exemplo n.º 6
0
        // ed05af
        private SpyRole() : base("spy",
                                 new Color(237f / 255f, 5f / 255f, 175f / 255f, 1))
        {
            InvisibleCooldown = CreateCooldown("invisible.cooldown");
            InvisibleEffect   = CreateCooldown("invisible.effect", 10f);
            DisguiseCooldown  = CreateCooldown("disguise.cooldown");

            _ResetOnMeeting = MakeToggle("disguise.reset_on_meeting", true);
        }
        void OnServerInitialized()
        {
            LoadConfig();

            if (this.config_data.Cooldowns.EnableCooldown)
            {
                // Initialize cooldown controller if requested to
                this.cooldown_controller = new CooldownController(this, this.config_data.Cooldowns.CooldownSecs, this.config_data.Cooldowns.CooldownPerPlayer);
            }
        }
Exemplo n.º 8
0
 // e67300
 private ScientistRole() : base("scientist",
                                new Color(230f / 255f, 115f / 255f, 0f / 255f, 1))
 {
     TimeWarpCooldown = CreateCooldown("timewarp.cooldown");
     TimeWarpEffect   = CreateCooldown("timewarp.effect", 10f);
     _TimeWarpSpeed   = MakeNumber("timewarp.speed", 0.75f,
                                   0.25f, 10.0f, 0.25f);
     _TimeWarpSelf = MakeToggle("timewarp.self", true);
     TasksCooldown = CreateCooldown("tasks.cooldown");
 }
Exemplo n.º 9
0
        protected void Attack(TTargetType target)
        {
            if (_reloadingTime > 0)
            {
                _reloadingTime -= Time.deltaTime;
                if (_reloadingTime <= 0)
                {
                    _bulletsCount = _up.ClipSize;
                }
                return;
            }

            if (_up.AttacksPerSecond <= 0.01f)
            {
                return;
            }
            if (target == null)
            {
                return;
            }
            if (!CooldownController.GetCooldown(_cooldownKey, 1 / _up.AttacksPerSecond))
            {
                return;
            }

            Attack attack = DefaultAttack;

            if (GameController.RandomGenerator.Next(0, 101) * 0.01f < CriticalChance)
            {
                attack *= CriticalMultiplier;
            }

            void FinalHitAction()
            {
                if (!(GameController.RandomGenerator.Next(0, 101) * 0.01f < _up.AttackAccuracy))
                {
                    return;
                }
                ;
                target.GetHit(attack, this);
                foreach (var action in OnHitEffects.ToArray())
                {
                    action?.Invoke(this, target);
                }
            }

            ProjectilesController.Instance.InitializeProjectile(attack, this, target, FinalHitAction);
            _bulletsCount--;
            if (_bulletsCount <= 0)
            {
                _reloadingTime = _up.ReloadTime;
            }
        }
Exemplo n.º 10
0
 protected override void attack()
 {
     // Checks if delay is active
     if (Time.time > nextFire)
     {
         nextFire = Time.time + fireRate;
         anim.SetBool("attacking", true);
         countdownAttack = Time.time;
         health.setInvincible(true, attackTime);
         boxCollider.enabled   = true;
         areaEffector.enabled  = true;
         boxCollider.isTrigger = true;
         gameObject.name       = "Feisty(Attack)";
         CooldownController.Cooldown3();
     }
 }
Exemplo n.º 11
0
    protected override void attack()
    {
        // Checks if delay is active
        if (Time.time > nextFire)
        {
            nextFire = Time.time + fireRate;
            GameObject           proj    = Instantiate(projectile, transform.position, Quaternion.identity);
            ProjectileController missile = proj.GetComponent <ProjectileController>();

            Vector3 dir = mousePos - transform.position;
            dir = transform.InverseTransformDirection(dir);
            float angle = (Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg);

            missile.transform.Rotate(new Vector3(0, 0, angle));
            missile.setAngle(angle);
            CooldownController.Cooldown3();
        }
    }
Exemplo n.º 12
0
 protected CooldownController CreateCooldown(string OptionName = "cooldown",
                                             float Value       = 30f, float Min = 5f, float Max = 60f, float Increment = 2.5f)
 {
     return(CooldownController.FromOption(Prefix, OptionName, Value, Min, Max, Increment));
 }
Exemplo n.º 13
0
 private void OnGUI()
 {
     ability  = parent.GetComponent <AbilitySlot>().ability;
     cooldown = parent.GetComponentInChildren <CooldownController>();
 }
Exemplo n.º 14
0
 public Pistol()
 {
     cooldownController = new CooldownController(Equipment.Instance, delay);
 }
Exemplo n.º 15
0
 public ExtraData(PlayerControl Player)
 {
     this.Player     = Player;
     RespawnCooldown = new CooldownController(new RespawnCooldownProvider());
 }
Exemplo n.º 16
0
 private void Awake()
 {
     instance = this;
 }
Exemplo n.º 17
0
 protected void CreateCooldown()
 {
     Cooldown = CooldownController.FromOption(Prefix);
 }
Exemplo n.º 18
0
 protected void Start()
 {
     cooldownController = new CooldownController(this, cooldown.TimeSpan);
 }
Exemplo n.º 19
0
 public void TestSetup()
 {
     controller = new CooldownController();
 }
Exemplo n.º 20
0
 protected void CreateDefaultCooldown()
 {
     Cooldown = CreateCooldown();
 }
Exemplo n.º 21
0
    // Update is called once per frame
    protected void Update()
    {
        fireRateCountdown -= Time.deltaTime;

        animGrounded = Physics2D.Raycast(new Vector2(transform.position.x, transform.position.y), new Vector2(0, -1), 0.8f, whatIsGround);

        if (animGrounded)
        {
            anim.SetBool("grounded", true);
        }
        else
        {
            anim.SetBool("grounded", false);
        }

        anim.SetBool("dash", false);

        sr = GetComponent <SpriteRenderer>();
        if (grounded)
        {
            jumpCount     = 0;
            walljumpCount = 0;
            airWaveDashed = false;
        }

        if (touchingRWall || touchingLWall)
        {
            grounded = false;
        }

        if (!grounded && jumpCount == 0)
        {
            // Fixes first jump not getting detected
            ++jumpCount;
        }

        anim.SetFloat("speed", Mathf.Abs(rb.velocity.x));

        //Basic WASD keypress
        if (Input.GetKeyDown(KeyCode.W) && jumpCount < maxJumpCount)
        {
            move(KeyCode.W);
            float vol = Random.Range(volLowRange, volHighRange);
            source.PlayOneShot(jumpSound, vol);
        }

        if (Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.A))
        {
            move(KeyCode.D);
            float vol = Random.Range(volLowRange, volHighRange);
            source.PlayOneShot(runSound, vol);
        }
        else if (Input.GetKeyUp(KeyCode.D))
        {
            rb.velocity = new Vector2(stopSpeed, rb.velocity.y);
        }
        else if (Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))
        {
            move(KeyCode.A);
            float vol = Random.Range(volLowRange, volHighRange);
            source.PlayOneShot(runSound, vol);
        }
        else if (Input.GetKeyUp(KeyCode.A))
        {
            rb.velocity = new Vector2(-stopSpeed, rb.velocity.y);
        }

        //Wavedash keypress
        if (Input.GetKey(KeyCode.Space) && Input.GetKey(KeyCode.D) && !waveDashed && !airWaveDashed)
        {
            dash(KeyCode.D);
            float vol = Random.Range(volLowRange, volHighRange);
            source.PlayOneShot(dashSound, vol);
        }
        else if (Input.GetKey(KeyCode.Space) && Input.GetKey(KeyCode.A) && !waveDashed && !airWaveDashed)
        {
            dash(KeyCode.A);
            float vol = Random.Range(volLowRange, volHighRange);
            source.PlayOneShot(dashSound, vol);
        }
        else if (Input.GetKey(KeyCode.Space) && Input.GetKey(KeyCode.W) && !waveDashed && !airWaveDashed)
        {
            dash(KeyCode.W);
            float vol = Random.Range(volLowRange, volHighRange);
            source.PlayOneShot(dashSound, vol);
        }
        else if (Input.GetKey(KeyCode.Space) && Input.GetKey(KeyCode.S) && !waveDashed && !airWaveDashed)
        {
            dash(KeyCode.S);
            float vol = Random.Range(volLowRange, volHighRange);
            source.PlayOneShot(dashSound, vol);
        }

        //Wall jumping
        if (Input.GetKeyDown(KeyCode.LeftShift) && touchingRWall && !grounded && walljumpCount < maxWallJumpCount)
        {
            RWallJump();
        }

        if (Input.GetKeyDown(KeyCode.LeftShift) && touchingLWall && !grounded && walljumpCount < maxWallJumpCount)
        {
            LWallJump();
        }

        // Shoot is 'Left Click'
        if (Input.GetMouseButton(0))
        {
            mousePos   = Input.mousePosition;
            mousePos.z = 0;
            mousePos   = Camera.main.ScreenToWorldPoint(mousePos);
            Debug.Log(mousePos);
            attack();
            mousePos = Input.mousePosition;

            //Plays sound only once
            if (!lockSound && fireRateCountdown <= 0)
            {
                float vol = Random.Range(volLowRange, volHighRange);
                source.PlayOneShot(attackSound, vol);
                fireRateCountdown = fireRate;
            }
            lockSound = true;
        }

        if (Input.GetMouseButtonUp(0))
        {
            lockSound = false;
        }

        // Parry is 'Right Click'
        if (Input.GetMouseButton(1))
        {
            if (canParry)
            {
                GetComponent <Health>().parry();
                parryTimer = 2.0f;
                canParry   = false;
                CooldownController.Cooldown2();
            }
        }

        if (Input.GetKeyDown(KeyCode.E))
        {
            usePower();
        }
    }
Exemplo n.º 22
0
 // 6a0dad
 private PsychicRole() : base("psychic",
                              new Color(106 / 255f, 13f / 255f, 173f / 255f, 1))
 {
     CreateDefaultCooldown();
     EffectCooldown = CreateCooldown("effect", 10f);
 }
Exemplo n.º 23
0
 protected new void Start()
 {
     base.Start();
     cooldown = new CooldownController(this, attackCooldown.TimeSpan);
 }