Exemplo n.º 1
0
        }   // end of PlayCollision()

        /// <summary>
        /// Play audio for actor/terrrain collision
        /// </summary>
        /// <param name="actor"></param>
        /// <param name="material">Material index.</param>
        public static void PlayCollision(GameThing actor, ushort material)
        {
            // Get the proper collision sound from the material index.
            if (!TerrainMaterial.IsValid(material, false, false))
            {
                //Debug.Assert(false, "Why do we have an invalid material here?");
                // Why?  Well because we sometimes clear the material in the feeler
                // collision testing.  So it's no longer a valid way to tell what
                // terrain we're over.  In general, it works when we're on the ground
                // but not when jumping.  Argh.

                collisionMetalSoft.Play(actor);
                return;
            }

            PlayActorCollision(actor);

            CollisionSound cs = TerrainMaterial.Get(material).CollisionSound;

            switch (cs)
            {
            case CollisionSound.plasticHard:
                collisionPlasticHard.Play(actor);
                break;

            case CollisionSound.plasticSoft:
                collisionPlasticSoft.Play(actor);
                break;

            case CollisionSound.metalHard:
                collisionMetalHard.Play(actor);
                break;

            case CollisionSound.metalSoft:
                collisionMetalSoft.Play(actor);
                break;

            case CollisionSound.rover:
                collisionRover.Play(actor);
                break;

            case CollisionSound.dirt:
                collisionDirt.Play(actor);
                break;

            case CollisionSound.grass:
                collisionGrass.Play(actor);
                break;

            case CollisionSound.rock:
                collisionRock.Play(actor);
                break;

            default:
                break;
            }
        }   // end of PlayCollision()
Exemplo n.º 2
0
    //// Private methods

    // Called before first update
    private void Start()
    {
        canMove = true;

        Collider2D coll2D = GetComponent <Collider2D>();

        playerHalfSize = coll2D != null?GetComponent <Collider2D>().bounds.extents : GetComponent <Collider>().bounds.extents;

        playerData = GetComponent <PlayerData>();

        collisionSound = GameObject.Find("CollisionSoundPlayer").GetComponent <CollisionSound>();
    }
Exemplo n.º 3
0
        }   // end of PlayCollision()

        private static void PlayActorCollision(GameThing actor)
        {
            CollisionSound cs = actor.CollisionSound;

            switch (cs)
            {
            case CollisionSound.plasticHard:
                collisionPlasticHard.Play(actor);
                break;

            case CollisionSound.plasticSoft:
                collisionPlasticSoft.Play(actor);
                break;

            case CollisionSound.metalHard:
                collisionMetalHard.Play(actor);
                break;

            case CollisionSound.metalSoft:
                collisionMetalSoft.Play(actor);
                break;

            case CollisionSound.rover:
                collisionRover.Play(actor);
                break;

            case CollisionSound.dirt:
                collisionDirt.Play(actor);
                break;

            case CollisionSound.grass:
                collisionGrass.Play(actor);
                break;

            case CollisionSound.rock:
                collisionRock.Play(actor);
                break;

            default:
                break;
            }
        }   // end of PlayActorCollision()
Exemplo n.º 4
0
    void Start()
    {
        DriverMaxSpeed = Random.Range(MaxSpeedRandom.x, MaxSpeedRandom.y);
        TurnDeadZone   = Random.Range(TurnDeadZoneRandom.x, TurnDeadZoneRandom.y);
        OuterLane      = Random.Range(0f, 1f) > 0.5;

        CS             = GetComponent <CollisionSound>();
        r              = GetComponent <Rigidbody>();
        r.centerOfMass = Mass.localPosition;
        Goal.SetParent(null);
        CurrentNode       = new Road.Node();
        CurrentNode.Index = -1;

        InitTune();

        GetRoad();
        InvokeRepeating("CheckWaiting", 10f, 10f);
        InvokeRepeating("ChangeLanes", Random.Range(0f, 25f), Random.Range(10f, 25f));
        ASC_Engine.Play();
    }