Ejemplo n.º 1
0
    void UpdatePlayer(float dt)
    {
        moveVec_ = Vector3.zero;

        renderer_.sprite = SimpleSpriteAnimator.GetAnimationSprite(Anim.Idle, Anim.DefaultAnimationFramesPerSecond);
        renderer_.flipX  = flipX_;
    }
Ejemplo n.º 2
0
    void UpdateInternal(float dt)
    {
        UpdateFlash();

        if (weaponRenderer_ != null)
        {
            weaponRenderer_.enabled = isHumanControlled_;
        }

        if (isHumanControlled_)
        {
            UpdateInternal_MouseControls(dt);
            camPositioner_.Target = lookAt_;
        }

        bool isRunning = latestFixedMovenentDirection_ != Vector3.zero;

        renderer_.sprite = SimpleSpriteAnimator.GetAnimationSprite(isRunning ? Anim.Run : Anim.Idle, Anim.DefaultAnimationFramesPerSecond);

        if (ShowCollisionDebug)
        {
            DrawCollisionDebug();
        }
        UpdateEffects(dt);
    }
Ejemplo n.º 3
0
    public void UpdateAnimation(Vector3 latestMovementDirection, bool isDead = false, bool isAttacking = false)
    {
        if (isDead)
        {
            renderer_.sprite = SpriteWhenDead;
        }
        else if (isAttacking)
        {
            renderer_.sprite = SimpleSpriteAnimator.GetAnimationSprite(Anim.Attack, Anim.DefaultAnimationFramesPerSecond, 0);
        }
        else
        {
            bool isRunning = latestMovementDirection != Vector3.zero;
            renderer_.sprite = SimpleSpriteAnimator.GetAnimationSprite(isRunning ? Anim.Run : Anim.Idle, Anim.DefaultAnimationFramesPerSecond, randomOffset_);
        }

        if (latestMovementDirection.x == 0)
        {
            renderer_.flipX = latestFlip_;
        }
        else
        {
            renderer_.flipX = latestMovementDirection.x < 0;
            latestFlip_     = renderer_.flipX;
        }
    }
Ejemplo n.º 4
0
    public void UpdateAnimation(Vector3 latestMovementDirection, bool isDead = false, bool isAttacking = false)
    {
        if (isDead)
        {
            renderer_.sprite = SpriteWhenDead;
        }
        else
        {
            renderer_.sprite = SimpleSpriteAnimator.GetAnimationSprite(Anim.Sprites, Anim.DefaultAnimationFramesPerSecond, randomOffset_);
        }

        renderer_.flipX = latestMovementDirection.x < 0;
    }
Ejemplo n.º 5
0
    IEnumerator <float> WanderCo(float startDelay)
    {
        if (!path_.HasPath)
        {
            yield break;
        }

        yield return(Timing.WaitForSeconds(startDelay));

        float t    = 0;
        float endT = path_.EndT;

        while (true)
        {
            var oldPos = transform_.position;
            var newPos = path_.GetPosAtTime(t);
            transform_.position = newPos;

            var  movement  = newPos - oldPos;
            bool flipX     = movement.x < 0;
            bool isRunning = movement.sqrMagnitude > 0.01f * 0.01f;
            renderer_.sprite = SimpleSpriteAnimator.GetAnimationSprite(isRunning ? Anim.Run : Anim.Idle, Anim.DefaultAnimationFramesPerSecond);
            renderer_.flipX  = flipX;

            if (t == 0)
            {
                ParticleScript.EmitAtPosition(ParticleScript.Instance.PlayerLandParticles, newPos, 5);
                ParticleScript.EmitAtPosition(ParticleScript.Instance.WallDestructionParticles, newPos, 5);
                ParticleScript.EmitAtPosition(ParticleScript.Instance.MuzzleFlashParticles, newPos, 1);
            }

            t += Time.unscaledDeltaTime;
            if (t >= endT)
            {
                ParticleScript.EmitAtPosition(ParticleScript.Instance.PlayerLandParticles, newPos, 5);
                ParticleScript.EmitAtPosition(ParticleScript.Instance.WallDestructionParticles, newPos, 5);
                ParticleScript.EmitAtPosition(ParticleScript.Instance.MuzzleFlashParticles, newPos, 1);

                gameObject.SetActive(false);
                yield break;
            }

            yield return(0);
        }
    }
Ejemplo n.º 6
0
    void UpdateInternal_KeyboardControls(float dt)
    {
        bool    hasRecentlyFiredWeapon   = CurrentWeapon.LatestFiringTimeUnscaled > Time.unscaledTime - 0.70f;
        Vector3 latestHorizontalMovement = new Vector3(latestFixedMovenentDirection_.x, 0, 0);
        Vector3 facingDirection          = hasRecentlyFiredWeapon ? CurrentWeapon.LatestFiringDirection : latestHorizontalMovement;

        if (facingDirection.x != 0)
        {
            latestFacingDirection_ = facingDirection.x;
        }

        flipX_ = latestFacingDirection_ < 0;
        weaponTransform_.localPosition = WeaponOffsetRight;

        bool isRunning = latestFixedMovenentDirection_ != Vector3.zero;

        if (isRunning)
        {
            lookAt_ = transform_.position + latestFixedMovenentDirection_ * LookAtOffset;
        }

        renderer_.sprite = SimpleSpriteAnimator.GetAnimationSprite(isRunning ? Anim.Run : Anim.Idle, Anim.DefaultAnimationFramesPerSecond);
        renderer_.flipX  = flipX_;

        // Weapon positioning
        var weaponOffset = WeaponOffsetRight;

        weaponOffset.x *= flipX_ ? -1 : 1;
        weaponTransform_.localPosition = weaponOffset;
        weaponRenderer_.flipX          = flipX_;
        float weaponRotation = 0;

        if (facingDirection.y < 0)
        {
            weaponRotation = -90;
        }
        else if (facingDirection.y > 0)
        {
            weaponRotation = 90;
        }

        weaponTransform_.rotation = Quaternion.Euler(0, 0, weaponRotation);
    }
Ejemplo n.º 7
0
 private void Update()
 {
     // TODO: flipX from player X
     renderer_.sprite = SimpleSpriteAnimator.GetAnimationSprite(Anim.Sprites, Anim.DefaultAnimationFramesPerSecond);
 }
Ejemplo n.º 8
0
 void Update()
 {
     renderer_.sprite = SimpleSpriteAnimator.GetAnimationSprite(Anim.Sprites, Anim.DefaultAnimationFramesPerSecond);
 }