Beispiel #1
0
 private void AllPlayersEnteredWormhole(MetaAsteroids_Wormhole wormhole)
 {
     cutout          = GameObject.Instantiate(Cutout).GetComponent <MetaAsteroids_Cutout>();
     currentWormhole = wormhole;
     cutout.ZoomIn(wormhole.transform.position, 1f, this);
     asteroidsManager.KillAll();
 }
    void OnTriggerEnter2D(Collider2D col)
    {
        MetaAsteroids_Wormhole wormhole = col.gameObject.GetComponent <MetaAsteroids_Wormhole>();

        if (wormhole != null && wormhole.gameObject.activeSelf)
        {
            targetWormhole        = wormhole;
            wormholeEntranceTimer = 0f;
        }
    }
Beispiel #3
0
    public void PlayerEnteredWormhole(MetaAsteroids_Wormhole wormhole)
    {
        playersInWormhole++;
        List <Player> players = PlayerManager.GetPlayers();

        Debug.Log(playersInWormhole);
        Debug.Log(players.Count);
        if (playersInWormhole == players.Count)
        {
            AllPlayersEnteredWormhole(wormhole);
        }
        phasePlaying = false;
    }
    // Update is called once per frame
    void Update()
    {
        if (freezeTimer > 0f)
        {
            freezeTimer -= Time.deltaTime;
            return;
        }

        if (targetWormhole != null)
        {
            // Move into wormhole.
            transform.position = Vector3.Lerp(transform.position, targetWormhole.transform.position, 0.025f);
            transform.Rotate(0f, 0f, 1000f * Time.deltaTime);
            if (Vector3.Distance(transform.position, targetWormhole.transform.position) < 0.01f)
            {
                // Enter the wormhole.
                wormholeEntranceTimer += Time.deltaTime;
                if (wormholeEntranceTimer >= WormholeEntranceTime)
                {
                    gameObject.SetActive(false);
                    metaGame.PlayerEnteredWormhole(targetWormhole);
                    targetWormhole = null;
                }
            }
        }
        else
        {
            // Move freely.
            Vector3 input = player.GetInputAxis();
            float   mag   = input.magnitude;

            float rotateMag = Mathf.Clamp01((mag - DeadZoneRadius) / (TurnZoneRadius - DeadZoneRadius));
            float moveMag   = Mathf.Clamp01((mag - TurnZoneRadius) / (MoveZoneRadius - TurnZoneRadius));

            float rotateSpeed = Mathf.Lerp(MinTurnSpeed, MaxTurnSpeed, rotateMag);
            rotateSpeed *= TurnMod;

            float      angle = Mathf.Atan2(-input.y, -input.x) * Mathf.Rad2Deg;
            Quaternion q     = Quaternion.AngleAxis(angle, Vector3.forward);
            transform.rotation = Quaternion.Slerp(transform.rotation, q, Time.deltaTime * rotateSpeed);

            float moveSpeed = Mathf.Lerp(MinMoveSpeed, MaxMoveSpeed, moveMag);
            moveSpeed         *= MoveMod;
            transform.position = transform.position + transform.right * moveSpeed * Time.deltaTime * -1f;
        }
    }