Exemplo n.º 1
0
    void Start()
    {
        cc           = GetComponent <CharacterController2D>();
        animator     = GetComponent <Animator>();
        sr           = GetComponent <SpriteRenderer>();
        rainbowTrail = GetComponent <TrailRenderer>();
        playerInput  = GetComponent <PlayerInput>();
        audioSource  = GetComponent <AudioSource>();

        // set screen bottom for death
        bottomDeath = CamToWorldUtility.GetCameraBoundsInWorld(cam).down.y;

        // set console controller id
        playerInput.Initialize(inputDeviceId);

        // set gravity and jump velocity based on desired height and apex time
        gravity      = -(2 * jumpHeight) / Mathf.Pow(jumpApexDelay, 2);
        jumpVelocity = Mathf.Abs(gravity * jumpApexDelay);

        // set default dash direction
        dashDirection = cc.CollisionState.horizontalDir;

        // set collision events
        cc.OnTriggerStayEvent += OnTriggerStayEvent;
        cc.OnTriggerExitEvent += OnTriggerExitEvent;

        // reset player pos, stats, etc
        initialPos = transform.position;

        Reset();
    }
Exemplo n.º 2
0
 public void Initialize(Camera cam, GameObject[] platforms, GameObject platformsContainer, GameObject[] deathRays, GameObject deathRaysContainer,
                        float leftCorner, float rightCorner, float startY, float deathRaysProbability, float deathRaysOffset, float initialVelocity, float velocityIncrement)
 {
     this.camBounds            = CamToWorldUtility.GetCameraBoundsInWorld(cam);
     this.platforms            = platforms;
     this.platformsContainer   = platformsContainer;
     this.deathRays            = deathRays;
     this.deathRaysContainer   = deathRaysContainer;
     this.leftCorner           = leftCorner;
     this.rightCorner          = rightCorner;
     this.currentGenY          = startY;
     this.deathRaysProbability = deathRaysProbability;
     this.deathRaysOffset      = deathRaysOffset;
     this.currentVelocity      = initialVelocity;
     this.velocityIncrement    = velocityIncrement;
 }
Exemplo n.º 3
0
    void Start()
    {
        Vector3 newPosition;
        float   z = transform.position.z;

        if (left)
        {
            newPosition = CamToWorldUtility.GetCameraBoundsInWorld(cam).left;
        }
        else
        {
            newPosition = CamToWorldUtility.GetCameraBoundsInWorld(cam).right;
        }

        newPosition.z      = z;
        transform.position = newPosition;
    }
Exemplo n.º 4
0
    void GeneratePlatforms()
    {
        CamToWorldUtility.CameraBounds camBounds = CamToWorldUtility.GetCameraBoundsInWorld(cam);
        float startY = camBounds.down.y;

        // left player
        float p1LeftCorner  = camBounds.left.x;
        float p1RightCorner = camBounds.up.x;

        p1PlatformsGen = gameObject.AddComponent <PlatformGenerator>();
        p1PlatformsGen.Initialize(cam, platforms, platformsContainer, deathRays, deathRaysContainer, p1LeftCorner, p1RightCorner, startY, deathRaysProbability, deathRaysOffset, initialVelocity, velocityIncrement);
        p1PlatformsGen.Generate();

        // right player
        float p2LeftCorner  = camBounds.up.x;
        float p2RightCorner = camBounds.right.x;

        p2PlatformsGen = gameObject.AddComponent <PlatformGenerator>();
        p2PlatformsGen.Initialize(cam, platforms, platformsContainer, deathRays, deathRaysContainer, p2LeftCorner, p2RightCorner, startY, deathRaysProbability, deathRaysOffset, initialVelocity, velocityIncrement);
        p2PlatformsGen.Generate();
    }