コード例 #1
0
ファイル: ActionDelayer.cs プロジェクト: MgCohen/Data-Run
 public TimeDelayer(float mtotal, UnityAction action)
 {
     totalTime = mtotal;
     startTime = Time.time;
     act       = action;
     delayer   = InstancedAction.DoRoutine(DelayCO(action, mtotal));
 }
コード例 #2
0
    public void TakeDamage(Vector2 sourcePoint, int amount = 1)
    {
        var direction = (transform.position - (Vector3)sourcePoint).normalized;

        ready = false;
        anim.SetTrigger("Hit");
        Invunerable();
        Health       -= amount;
        body.velocity = Vector2.zero;
        if (dashTween != null)
        {
            dashTween.Kill(true);
        }
        body.DOKill();

        body.AddForce(direction * dashSpeed * 350, ForceMode2D.Force);
        InstancedAction.DelayAction(() =>
        {
            ready = true;
            if (Health <= 0)
            {
                Manager.instance.LoseEvent.Raise();
                gameObject.SetActive(false);
            }
        }, 0.25f);
    }
コード例 #3
0
ファイル: Shell.cs プロジェクト: MgCohen/Kart-old
 private void Start()
 {
     rb          = GetComponent <Rigidbody>();
     child       = transform.GetChild(0);
     rb.velocity = transform.forward * Speed;
     InstancedAction.DelayAction(() => { Destroy(gameObject); }, lifeTime);
 }
コード例 #4
0
 public void Invunerable()
 {
     invunerable = true;
     InstancedAction.DelayAction(() =>
     {
         invunerable = false;
     }, invunerableTime);
 }
コード例 #5
0
 private void Kill()
 {
     if (!hit)
     {
         hit = true;
         anim.SetTrigger("Hit");
         InstancedAction.DelayAction(() => { gameObject.Kill(); }, 0.3f);
     }
 }
コード例 #6
0
ファイル: ActionDelayer.cs プロジェクト: MgCohen/Data-Run
 public void Pause(float time)
 {
     if (paused)
     {
         return;
     }
     Pause();
     InstancedAction.DelayAction(Resume, time);
 }
コード例 #7
0
 private void Single()
 {
     if (tap)
     {
         tap          = false;
         m_HopPressed = true;
         InstancedAction.DelayAction(() => { m_HopPressed = false; }, 0);
     }
 }
コード例 #8
0
ファイル: ItemBox.cs プロジェクト: MgCohen/Kart-old
 private void OnTriggerEnter(Collider other)
 {
     if (other.transform.tag == "Kart")
     {
         var bag = other.GetComponent <KartBag>();
         bag.AddItem(bag.GetItem());
         boxModel.SetActive(false);
         InstancedAction.DelayAction(() => { boxModel.SetActive(true); }, 2f);
     }
 }
コード例 #9
0
 public static void ChangeScale(float scale, float duration)
 {
     Time.timeScale      = scale;
     Time.fixedDeltaTime = 0.02F * Time.timeScale;
     Normal = false;
     InstancedAction.DelayAction(() =>
     {
         Resume();
     }, duration);
 }
コード例 #10
0
ファイル: ActionDelayer.cs プロジェクト: MgCohen/Data-Run
    public void Resume()
    {
        if (!paused)
        {
            return;
        }
        paused = false;
        var delayed = InstancedAction.DelayAction(act, totalTime - elapsedOnPause);

        delayer = delayed.delayer;
    }
コード例 #11
0
 private void Tap(LeanFinger finger)
 {
     if (!tap)
     {
         tap = true;
         InstancedAction.DelayAction(Single, 0.15f);
     }
     else
     {
         Double();
     }
 }
コード例 #12
0
 public void Change()
 {
     if (!fadeIn)
     {
         UnityEngine.SceneManagement.SceneManager.LoadScene(index);
     }
     else
     {
         image.gameObject.SetActive(true);
         image.DOFade(1, fadeTime);
         InstancedAction.DelayAction(() => UnityEngine.SceneManagement.SceneManager.LoadScene(index), fadeTime);
     }
 }
コード例 #13
0
 public static void Stop(float duration = 0)
 {
     Time.timeScale      = 0.0f;
     Time.fixedDeltaTime = 0.02F * Time.timeScale;
     Normal = false;
     if (duration == 0)
     {
         return;
     }
     InstancedAction.DelayAction(() =>
     {
         Resume();
     }, duration);
 }
コード例 #14
0
ファイル: Player.cs プロジェクト: MgCohen/Adrenaline
 public void Shot()
 {
     aiming    = true;
     shotReady = false;
     Aim();
     InstancedAction.DelayAction(() => shotReady = true, 1 / gun.gun.fireRate);
     if (holsterTime != null)
     {
         holsterTime.Kill();
     }
     gunAnim.SetTrigger("Shot");
     Instantiate(gun.gun.bullet, gunPoint.position, gunPoint.rotation);
     holsterTime = InstancedAction.DelayAction(() => { aiming = false; AimOff(); }, aimingTime);
 }
コード例 #15
0
 public void ChangeColor()
 {
     currentColorIndex = nextColorIndex;
     foreach (var p in driftParticles.particles)
     {
         var j = p.main;
         j.startColor = particleColor[nextColorIndex];
     }
     nextColorIndex++;
     if (nextColorIndex <= 2)
     {
         delayer = InstancedAction.DelayAction(ChangeColor, 1f);
     }
     else
     {
         nextColorIndex = 0;
     }
 }
コード例 #16
0
 protected override void OnSelect(LeanFinger finger)
 {
     drag = true;
     InstancedAction.DelayAction(() =>
     {
         if (drag)
         {
             isSelected = true;
             SetReference(finger);
             selectedFinger = finger;
             CornerRotator.SetActive(true);
             if (menu.fixTween != null)
             {
                 menu.fixTween.Kill();
             }
         }
     }, 0.35f);
 }
コード例 #17
0
 public void Play()
 {
     if (!playing)
     {
         action.Invoke();
         if (fixedDuration)
         {
             timer = InstancedAction.DelayAction(() => { completed = true; }, duration);
         }
     }
     else
     {
         if (paused)
         {
             timer.Resume();
             paused = false;
         }
     }
 }
コード例 #18
0
 public void Dash()
 {
     if (enemy.dead)
     {
         return;
     }
     enemy.immune = true;
     //path.rb.DOMove((Vector2)transform.position + (strikeDirection * force), 0.5f);
     Debug.Log(strikeDirection);
     path.rb.AddForce(strikeDirection * strikeForce, ForceMode2D.Impulse);
     InstancedAction.DelayAction(() =>
     {
         path.rb.velocity = Vector2.zero;
     }, 0.5f);
     InstancedAction.DelayAction(() =>
     {
         enemy.immune = false;
         anim.SetTrigger("Up");
     }, 1f);
 }
コード例 #19
0
ファイル: Player.cs プロジェクト: MgCohen/Adrenaline
 public void Dash()
 {
     dashing   = true;
     isDashing = true;
     particles.Play();
     if (CheckGround())
     {
         body.AddForce(transform.right * dashForce, ForceMode2D.Force);
     }
     else
     {
         body.velocity = new Vector2(0, 0);
         //var x = (anim.GetBool("Moving") == true) ? transform.right.x : 0;
         ////var y = Input.GetAxisRaw("Vertical");
         //if (y == 0) y = 1;
         //body.AddForce(new Vector2(x, y) * dashForce, ForceMode2D.Force);
         var dir = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
         dir   = dir.normalized * 2f;
         dir.z = 0;
         body.AddForce(dir * dashForce, ForceMode2D.Force);
     }
     dashTimer = InstancedAction.DelayAction(() => { isDashing = false; body.velocity = Vector2.zero; freeFall = true; }, dashTime);
 }
コード例 #20
0
    public void SetBehaviour()
    {
        var playerPos   = Player.instance.transform.position;
        var playerDist  = (playerPos - transform.position).magnitude;
        var mask        = LayerMask.GetMask("Props");
        var playerSight = !Physics2D.Raycast(transform.position, playerPos - transform.position, playerDist, mask);

        if (playerDist < circlingRange && playerSight && !striked)
        {
            behaviour = EnemyBehaviour.Agressive;
            if (!checking)
            {
                checking = true;
                if (timer < checkTime)
                {
                    timer = checkTime;
                }
            }
            else
            {
                timer -= Time.deltaTime;
                if (timer <= 0 && checking)
                {
                    if (playerDist <= circlingRange * 1.2f)
                    {
                        Debug.Log("STRIKE");
                        striked          = true;
                        path.stopped     = true;
                        path.rb.velocity = Vector2.zero;
                        anim.SetTrigger("Strike");
                        strikeDirection = (playerPos - transform.position).normalized;
                    }
                    else
                    {
                        checking = false;
                    }
                }
            }
        }

        if ((playerDist < NearRange * 0.75 && !playerSight) || (playerDist < NearRange && playerSight))
        {
            if (behaviour != EnemyBehaviour.Near)
            {
                path.GetRandomOffset();
            }
            behaviour = EnemyBehaviour.Near;
            path.SetTarget(path.GetPointOnRandomDirection(Player.instance.transform, 10f, circlingRange));
        }
        else
        {
            if ((behaviour == EnemyBehaviour.Idle && path.reachedEnd) || behaviour != EnemyBehaviour.Idle)
            {
                var chance = Random.value;
                if (chance > 0.3f)
                {
                    path.SetTarget(path.GetPointNearTarget(transform, IdleRange));
                }
                else
                {
                    path.stopped = true;
                    InstancedAction.DelayAction(() => { path.stopped = false; }, 1f);
                }
            }
            behaviour = EnemyBehaviour.Idle;
        }
    }
コード例 #21
0
 public ActionQueue()
 {
     InstancedAction.RegisterUpdate(CheckQueue);
 }
コード例 #22
0
 public void HandleBehaviour()
 {
     if (idling)
     {
         return;
     }
     if (behaviour == EnemyBehaviour.Idle)
     {
         if (path.reachedEnd)
         {
             var chance = Random.value;
             Debug.Log(chance);
             if (chance <= 0.1f)
             {
                 idling          = true;
                 path.reachedEnd = false;
                 path.NullTarget();
                 InstancedAction.DelayAction(() =>
                 {
                     idling          = false;
                     path.reachedEnd = true;
                 }, 1f);
             }
             else
             {
                 path.SetTarget(path.GetPointNearTarget(transform, idleRange));
             }
         }
     }
     else if (behaviour == EnemyBehaviour.Near)
     {
         if (path.reachedEnd)
         {
             path.SetTarget(path.GetPointOnDirection(Player.instance.transform, 20f, shotRange, (transform.position - Player.instance.transform.position)));
         }
     }
     else
     {
         if (lastBehaviour != EnemyBehaviour.Agressive)
         {
             path.SetTarget(path.GetPointOnDirection(Player.instance.transform, 20f, shotRange, (transform.position - Player.instance.transform.position)));
         }
         else if (path.reachedEnd)
         {
             var offset = Random.Range(15, 80);
             path.SetTarget(path.GetPointOnDirection(Player.instance.transform, offset, shotRange, (transform.position - Player.instance.transform.position), true));
         }
         if (path.targetDistance <= shotRange * 1.2f && timer <= 0)
         {
             var direction = Player.instance.transform.position - bulletPoint.position;
             sprite.flipX = (direction.x < 0);
             anim.SetTrigger("Shot");
             timer           = shotCd;
             idling          = true;
             shoting         = true;
             shotDirection   = direction.normalized;
             path.reachedEnd = false;
             path.NullTarget();
             InstancedAction.DelayAction(() =>
             {
                 idling          = false;
                 path.reachedEnd = true;
             }, 1f);
         }
     }
 }
コード例 #23
0
ファイル: BoostItem.cs プロジェクト: MgCohen/Kart-old
 public override void Trigger(KartMovement kart)
 {
     InstancedAction.DoRoutine(ApplyEffect(kart));
 }