public void ToggleBeacon()
        {
            //changed = true;
            for (int i = 0; i < animStages.Length; i++)
            {
                if (beaconActivated)
                {
                    UnityEngine.Debug.Log("Deactivating Beacon");

                    foreach (var animation in part.FindModelAnimators(animStages[i]))
                    {
                        //animation[animationName].speed = 0;
                        // animation[animationName].enabled = false;
                        rampDirection = RampDirection.down;
                        // animation.Play(animationName);
                    }
                }
                else
                {
                    UnityEngine.Debug.Log("Activating Beacon");
                    foreach (var animation in part.FindModelAnimators(animStages[i]))
                    {
                        //animation[animationName].speed = 1;
                        //animation[animationName].enabled = true;
                        rampDirection = RampDirection.up;
                        //animation.Play(animationName);
                    }
                }
            }
            beaconActivated = !beaconActivated;
            UpdateEvents();
        }
Пример #2
0
    public List <Ramp> Track; // Initialised in inspector

    public void BuildRamp(RampDirection direction, Action onBallEnteredCb)
    {
        Ramp    previous    = Track[Track.Count - 1];
        Vector3 prevXYEuler = new Vector3(previous.transform.eulerAngles.x, previous.transform.eulerAngles.y, 0f);
        Ramp    r           = Instantiate(RampPrefab, previous.EndConnector.position, RampRotations[direction] * Quaternion.Euler(prevXYEuler)).GetComponent <Ramp>();

        r.OnBallEnteredCb = onBallEnteredCb;
        Track.Add(r);
    }
Пример #3
0
 // Start is called before the first frame update
 void Start()
 {
     health         = 100;
     rigidbody2D    = GetComponent <Rigidbody2D>();
     rampDirection  = RampDirection.NONE;
     player         = GameObject.FindObjectOfType <PlayerScript>();
     hitSound       = GetComponent <AudioSource>();
     animator       = GetComponent <Animator>();
     spriteRenderer = GetComponent <SpriteRenderer>();
 }
 private static bool CheckForFlatRampPart(double vTotal, double vTarget, RampDirection direction)
 {
     if (direction == RampDirection.Decelerate)
     {
         return(vTotal > vTarget);
     }
     else
     {
         return(vTotal <= vTarget);
     }
 }
Пример #5
0
        public async Task <LightStatus> RampAsync(InsteonId dst, RampDirection dir, int durationMs = 0)
        {
            LightStatus s = await StartRampAsync(dst, dir);

            if (durationMs > 0)
            {
                await Task.Delay(durationMs);

                s = await StopRampAsync(dst);
            }
            return(s);
        }
 // Start is called before the first frame update
 void Start()
 {
     m_rigidBody2D    = GetComponent <Rigidbody2D>();
     m_spriteRenderer = GetComponent <SpriteRenderer>();
     m_animator       = GetComponent <Animator>();
     rampDirection    = RampDirection.NONE;
     dustTrail        = GetComponentInChildren <ParticleSystem>();
     dispText         = false;
     life             = 3;
     victory          = false;
     isPaused         = false;
     score            = 0;
     isAttacking      = false;
 }
    private void _LookInFront()
    {
        var wallHit = Physics2D.Linecast(transform.position, lookInFrontPoint.position, collisonWallLayer);

        if (wallHit)
        {
            if (!wallHit.collider.CompareTag("Ramps"))
            {
                rampDirection = RampDirection.DOWN;
            }
            else
            {
                rampDirection = RampDirection.UP;
            }
        }
    }
Пример #8
0
    void LookInFront()
    {
        var wallhit = Physics2D.Linecast(transform.position, lookInFrontP.position, wall);

        if (wallhit)
        {
            if (!wallhit.collider.CompareTag("ramp"))
            {
                if (!onRamp && transform.rotation.z == 0)
                {
                    FlipX();
                }
                rampdir = RampDirection.DOWN;
            }
            else
            {
                rampdir = RampDirection.UP;
            }
        }
        Debug.DrawLine(transform.position, lookInFrontP.position, Color.red);
    }
Пример #9
0
    private void _LookInFront()
    {
        if (!isGrounded)
        {
            rampDirection = RampDirection.NONE;
            return;
        }

        var wallHit = Physics2D.Linecast(transform.position, lookInFrontPoint.position, collisionWallLayer);

        if (wallHit && isOnSlope())
        {
            rampDirection = RampDirection.UP;
        }
        else if (!wallHit && isOnSlope())
        {
            rampDirection = RampDirection.DOWN;
        }

        Debug.DrawLine(transform.position, lookInFrontPoint.position, Color.red);
    }
    private void _LookInFront()
    {
        var wallHit = Physics2D.Linecast(transform.position, lookAheadPoint.position, colWallLayer);

        if (wallHit)
        {
            if (!wallHit.collider.CompareTag("Ramps"))
            {
                if (!onRamp)
                {
                    _FlipX();
                }
                rampDirection = RampDirection.DOWN;
            }
        }
        else
        {
            rampDirection = RampDirection.UP;
        }

        Debug.DrawLine(transform.position, lookAheadPoint.position, Color.green);
    }
Пример #11
0
    private void _LookInFront()
    {
        var wallHit = Physics2D.Linecast(transform.position, lookInFrontPoint.position, collisionWallLayer);

        if (wallHit)
        {
            if (!wallHit.collider.CompareTag("Ramps"))
            {
                if (!onRamp && transform.rotation.z == 0.0f)
                {
                    _FlipX();
                }

                rampDirection = RampDirection.DOWN;
            }
            else
            {
                rampDirection = RampDirection.UP;
            }
        }

        Debug.DrawLine(transform.position, lookInFrontPoint.position, Color.red);
    }
Пример #12
0
    //looking in front
    private void _LookInFront()
    {
        var wallhit = Physics2D.Linecast(transform.position, LookInFrontPoint.position, CollisionWallLayer);

        if (wallhit)
        {
            if (!wallhit.collider.CompareTag("Ramps"))
            {
                if (!OnRampHit && transform.rotation.z == 0)
                {
                    _flipX();
                }

                rampDir = RampDirection.DOWN;
            }
            else
            {
                rampDir = RampDirection.UP;
            }
        }

        Debug.DrawLine(transform.position, LookInFrontPoint.position, Color.black);
    }
Пример #13
0
    void LookAhead()
    {
        var groundhit = Physics2D.Linecast(transform.position, lookAheadP.position, ground);

        if (groundhit)
        {
            if (groundhit.collider.CompareTag("ramp"))
            {
                onRamp = true;
            }
            if (groundhit.collider.CompareTag("platform"))
            {
                onRamp = false;
            }
            isGroundAhead = true;
        }
        else
        {
            rampdir       = RampDirection.DOWN;
            isGroundAhead = false;
        }

        Debug.DrawLine(transform.position, lookAheadP.position, Color.green);
    }
Пример #14
0
 // Start is called before the first frame update
 void Start()
 {
     rigidbody2D   = GetComponent <Rigidbody2D>();
     rampDirection = RampDirection.NONE;
     player        = GameObject.FindObjectOfType <PlayerBehaviour>();
 }
Пример #15
0
 // Start is called before the first frame update
 void Start()
 {
     m_rigidbody2D = GetComponent <Rigidbody2D>();
     rampDirection = RampDirection.NONE;
 }
Пример #16
0
 public Task <LightStatus> StartRampAsync(InsteonId dst, RampDirection dir)
 => Send <LightStatus>(dst, Command.RampStart, (byte)dir);
        public void LateUpdate()
        {
            if (!HighLogic.LoadedSceneIsFlight && !HighLogic.LoadedSceneIsEditor || rampDirection == RampDirection.none)
            {
                return;
            }

            string activeAnim   = animStages[animStage];
            int    curAnimStage = animStage;

            foreach (var anim in part.FindModelAnimators(activeAnim))
            {
                if (anim != null)
                {
                    float origSpd = anim[activeAnim].speed;
                    switch (rampDirection)
                    {
                    case RampDirection.up:
                        if (ramp < 1f)
                        {
                            ramp += animationRampSpeed;
                        }
                        if (ramp > 1f)
                        {
                            ramp = 1f;
                            animStage++;
                        }
                        break;

                    case RampDirection.down:
                        if (ramp > 0)
                        {
                            ramp -= animationRampSpeed;
                        }
                        if (ramp < 0)
                        {
                            ramp = 0f;
                            animStage--;
                        }
                        break;
                    }

                    if (curAnimStage < animStages.Length - 1)
                    {
                        anim[activeAnim].normalizedTime = ramp;
                    }
                    else
                    {
                        anim[activeAnim].speed = customAnimationSpeed * ramp;
                    }
                    if (ramp == 0)
                    {
                        if (animStage < 0)
                        {
                            animStage     = 0;
                            rampDirection = RampDirection.none;
                        }
                        else
                        {
                            ramp = 1;
                        }
                    }
                    else if (ramp == 1)
                    {
                        if (animStage >= animStages.Length)
                        {
                            animStage     = animStages.Length - 1;
                            rampDirection = RampDirection.none;
                        }
                        else
                        {
                            ramp = 0;
                        }
                    }

                    anim.Play(activeAnim);
                }
                else
                {
                    Debug.Log("anim is null");
                }
            }
        }
    public void toggleEvent()
    {
        Events["toggleEvent"].active = false; //see if this removes the button when clicking
        isAnimating = true;

        //if (startDeployed && reverseAnimation && anim[animationName].normalizedTime == 0f)
        //    anim[animationName].normalizedTime = 0.999f;

        if (reverseAnimation)
        {
            Actions["toggleAction"].guiName = startEventGUIName;
            Events["toggleEvent"].guiName   = startEventGUIName;
            if (toggleActionName != string.Empty)
            {
                Actions["toggleAction"].guiName = toggleActionName;
            }
            // Following two commented out lines (anim[animationName].speed =, and anim.Play) now taken care of in LateUpdate
            //anim[animationName].speed = -1f *  customAnimationSpeed;
            if (anim[animationName].normalizedTime == 0f || anim[animationName].normalizedTime == 1f)
            {
                anim[animationName].normalizedTime = 1f;
            }

            anim.Play(animationName);
            startDeployed = false; // to get the hangar toggle button state right
            if (startRetractEffect != string.Empty)
            {
                part.Effect(startRetractEffect);
                Debug.Log("start retract effect");
            }
            rampDirection = RampDirection.down;
        }
        else
        {
            Actions["toggleAction"].guiName = endEventGUIName;
            Events["toggleEvent"].guiName   = endEventGUIName;
            if (toggleActionName != string.Empty)
            {
                Actions["toggleAction"].guiName = toggleActionName;
            }
            // Following two commented out lines (anim[animationName].speed =, and anim.Play) now taken care of in LateUpdate
            //anim[animationName].speed = 1f * customAnimationSpeed;
            if (anim[animationName].normalizedTime == 0f || anim[animationName].normalizedTime == 1f)
            {
                anim[animationName].normalizedTime = 0f;
                Debug.Log("normalizedTime 2 ");
            }

            anim.Play(animationName);
            startDeployed = true; // to get the hangar toggle button state right
            if (startDeployEffect != string.Empty)
            {
                part.Effect(startDeployEffect);
                Debug.Log("start deploy effect");
            }
            rampDirection = RampDirection.up;
        }

        reverseAnimation = !reverseAnimation;
        oldspeed         = -9999f;

        //if (isOneShot)
        //{
        //    locked = true;
        //    Events["toggleEvent"].active = false;
        //}
    }
Пример #19
0
 // Start is called before the first frame update
 void Start()
 {
     rb      = GetComponent <Rigidbody2D>();
     rampdir = RampDirection.NONE;
 }
Пример #20
0
        unsafe internal static void RampPCM16Volume(ref byte[] pcm16Samples, int length, RampDirection direction)
        {
            int count = length / 2;

            fixed(byte *p = pcm16Samples)
            for (int sampleIndex = 1; sampleIndex < count; sampleIndex++)
            {
                float volumeScalar;

                volumeScalar = sampleIndex / (float)count;
                if (direction == RampDirection.FullToZero)
                {
                    volumeScalar = 1.0f - volumeScalar;
                }
                ApplyVolumeScalar(volumeScalar, p, sampleIndex);
            }
        }
Пример #21
0
        public void UpdateAnimations()
        {
            if (!(HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) || rampDirection == RampDirection.none)
            {
                return;
            }

            string activeAnim   = animationStages[animStage];
            int    curAnimStage = animStage;

            var mas = part.FindModelAnimators(activeAnim).ToList();

            for (int i = mas.Count - 1; i >= 0; i--)
            {
                var anim = mas[i];
                //}
                //foreach (var anim in part.FindModelAnimators(activeAnim))
                //{
                if (anim != null)
                {
                    float origSpd = anim[activeAnim].speed;
                    if (rampDirection == RampDirection.up)
                    {
                        if (ramp < 1f)
                        {
                            ramp += animationRampSpeed;
                        }
                        if (ramp > 1f)
                        {
                            ramp = 1f;
                            animStage++;
                        }
                    }
                    else if (rampDirection == RampDirection.down)
                    {
                        if (ramp > 0)
                        {
                            ramp -= animationRampSpeed;
                        }
                        if (ramp < 0)
                        {
                            ramp = 0f;
                            animStage--;
                        }
                    }


                    if (curAnimStage < animationStages.Length - 1)
                    {
                        anim[activeAnim].normalizedTime = ramp;
                    }
                    else
                    {
                        anim[activeAnim].speed = customAnimationSpeed * ramp;
                    }

                    if (ramp == 0)
                    {
                        if (animStage < 0)
                        {
                            animStage     = 0;
                            rampDirection = RampDirection.none;
                        }
                        else
                        {
                            ramp = 1;
                        }
                    }
                    else if (ramp == 1)
                    {
                        if (animStage >= animationStages.Length)
                        {
                            animStage     = animationStages.Length - 1;
                            rampDirection = RampDirection.none;
                        }
                        else
                        {
                            ramp = 0;
                        }
                    }

                    anim.Play(activeAnim);
                }
            }
        }
Пример #22
0
 internal static unsafe void RampPCM16Volume(ref byte[] pcm16Samples, int length, RampDirection direction)
 {
     int count = length / 2;
     fixed (byte* p = pcm16Samples)
         for (int sampleIndex = 1; sampleIndex < count; sampleIndex++)
         {
             float volumeScalar;
             volumeScalar = sampleIndex / (float)count;
             if (direction == RampDirection.FullToZero)
                 volumeScalar = 1.0f - volumeScalar;
             ApplyVolumeScalar(volumeScalar, p, sampleIndex);
         }
 }