コード例 #1
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.tag == "Player")
        {
            PlatformerPlayer player = collider.gameObject.GetComponent <PlatformerPlayer>();

            if (player.hasRedKey && doorType == DOOR_TYPE.RED)
            {
                Destroy(gameObject);
            }

            if (player.hasBlueKey && doorType == DOOR_TYPE.BLUE)
            {
                Destroy(gameObject);
            }

            if (player.hasGreenKey && doorType == DOOR_TYPE.GREEN)
            {
                Destroy(gameObject);
            }

            if (player.groundPounding && doorType == DOOR_TYPE.GROUND)
            {
                Destroy(gameObject);
            }
        }
    }
コード例 #2
0
    void AddPlayerToMap()
    {
        player_x = start_player_x;
        player_y = start_player_y;

        streamingMap.DrawMap(player_x, player_y, 1, drawRadius, true);

        //We want to draw the map before we add the player
        player = GameObject.Instantiate(playerPrefab) as PlatformerPlayer;

        Vector3 coords = BlockUtilities.GetMathematicalPosition(streamingMap.blockMap, player_x, player_y, 0);

        player.transform.parent = streamingMap.blockMap.transform;

        player.transform.localPosition = coords;

        player.InitializeEntity(streamingMap.blockMap);
    }
コード例 #3
0
ファイル: StreamingWorld.cs プロジェクト: charliehuge/GGJ13
    void AddPlayerToMap()
    {
        player_x = start_player_x;
        player_y = start_player_y;

        streamingMap.DrawMap(player_x,player_y,1,drawRadius,true);

        //We want to draw the map before we add the player
        player = GameObject.Instantiate(playerPrefab) as PlatformerPlayer;

        Vector3 coords = BlockUtilities.GetMathematicalPosition(streamingMap.blockMap,player_x,player_y,0);

        player.transform.parent = streamingMap.blockMap.transform;

        player.transform.localPosition = coords;

        player.InitializeEntity(streamingMap.blockMap);
    }
    void OnTriggerEnter2D(Collider2D collider)
    {
        PlatformerPlayer player = collider.GetComponent <PlatformerPlayer>();

        if (player != null)
        {
            switch (type)
            {
            case Item.ITEM_TYPE.DANGO:
                player.collectables++;
                break;

            case Item.ITEM_TYPE.HEALTH:
                player._health.health++;
                break;

            case Item.ITEM_TYPE.DOUBLE_JUMP:
                player.canDoubleJump = true;
                break;

            case Item.ITEM_TYPE.GROUND_POUND:
                player.canGroundPound = true;
                break;

            case Item.ITEM_TYPE.DASH:
                player.canDash = true;
                break;

            case Item.ITEM_TYPE.RED_KEY:
                player.hasRedKey = true;
                break;

            case Item.ITEM_TYPE.GREEN_KEY:
                player.hasGreenKey = true;
                break;

            case Item.ITEM_TYPE.BLUE_KEY:
                player.hasBlueKey = true;
                break;
            }
            Destroy(gameObject);
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        //some of this code is taken from:
        //https://www.youtube.com/watch?v=t0326lvRIK0
        if (other.tag == "ground")
        {
            _body.velocity = Vector2.zero;
            if (_direction == 1)
            {
                _sprite.flipX = true;
            }
            else
            {
                _sprite.flipX = false;
            }
            _body.AddForce(new Vector2(moveSpeed * _direction, bounceSpeed), ForceMode2D.Impulse);
        }

        if (other.tag == "Player")
        {
            other.GetComponent <Health>().health--;

            //knockback code from:
            //https://www.youtube.com/watch?v=sdGeGQPPW7E
            PlatformerPlayer player = other.GetComponent <PlatformerPlayer>();
            player.knockbackCount = player.knockbackMaxTime;

            if (other.transform.position.x < transform.position.x)
            {
                player.knockFromRight = true;
            }
            else
            {
                player.knockFromRight = false;
            }

            _direction    *= -1;
            _body.velocity = new Vector2(moveSpeed * _direction, _body.velocity.y);
        }
    }
コード例 #6
0
    void Update()
    {
        if (_song.time > _timeUntilNextBeat)
        {
            _timeUntilNextBeat       += _beatDelta;
            PlatformerPlayer.InMyZone = false;
            ChangeActiveBeatGroup();
        }

        if (_song.time > _timeUntilPointsCheck)
        {
            if (PlatformerPlayer.InMyZone)
            {
                PlatformerPlayer.AddScore();
            }
            _timeUntilPointsCheck += _pointsDelta;
        }
        if (_song.time >= _song.clip.length)
        {
            pauseMenu.EndPause();
        }
        SongManager();
    }
コード例 #7
0
 private void Awake()
 {
     Instance = this;
 }
 // Start is called before the first frame update
 void Start()
 {
     _animation = GetComponent <Animator>();
     player     = GetComponent <PlatformerPlayer>();
 }
コード例 #9
0
 void Start()
 {
     playerController = GetComponent <PlatformerPlayer> ();
 }