示例#1
0
    // Update is called once per frame
    void Update()
    {
        if (!!worldGO && alpha < 1f)
        {
            World   w = worldGO.GetComponent <World>();
            Tilemap t = GetComponent <Tilemap>();
            if (!!w && !!t)
            {
                if (w.world_substate >= subform_depth)
                {
                    alpha        = t.color.a + fade_in_step;
                    t.color      = new Color(255, 255, 255, alpha);
                    tileIsActive = true;
                }
            }
        }

        if (!collider_activated && tileIsActive)
        {
            TilemapCollider2D tc2d = GetComponent <TilemapCollider2D>();
            if (!!tc2d)
            {
                tc2d.enabled       = true;
                collider_activated = true;
            }
        }
    }
    private void Awake()
    {
        DontDestroyOnLoad(gameObject);

        isAirColliderPassing    = false;
        isAirColliderPassingEnd = false;

        playerCollider = GetComponent <CapsuleCollider2D>();
        isFalling      = false;

        stat = GetComponent <PlayerStats>();
        playerCol_Control = GetComponent <PlayerColliderController>();

        verticalVelocity = 9.8f;
        rigidbody2       = GetComponent <Rigidbody2D>();
        anim             = GetComponentInChildren <Animator>();

        spriteTrans = transform.GetChild(0);
        flipScale   = spriteTrans.localScale;

        maxAttackAnimSpeed = MAX_NORMAL_ATTACK_ANIM_TIME;     //애니메이션 최대 속도 설정

        layerMask = 1 << 10 | 1 << 11 | 1 << 15;

        tileMaplCollider = GameObject.FindGameObjectWithTag("Air").transform.GetComponent <TilemapCollider2D>();
        states.Add(PlayerState.IDLE, GetComponent <PlayerIDLE>());
        states.Add(PlayerState.WALK, GetComponent <PlayerWALK>());
        states.Add(PlayerState.JUMP, GetComponent <PlayerJUMP>());
        states.Add(PlayerState.ATTACK, GetComponent <PlayerATTACK>());
        states.Add(PlayerState.DASH, GetComponent <PlayerDASH>());
        states.Add(PlayerState.DOWN, GetComponent <PlayerDOWN>());
        states.Add(PlayerState.DEAD, GetComponent <PlayerDEAD>());
        states.Add(PlayerState.SHOT, GetComponent <PlayerSHOT>());
    }
    private void Start()
    {
        tileRenderer = GetComponent <TilemapRenderer>();
        tileCollider = GetComponent <TilemapCollider2D>();

        player.OnJump.AddListener(Switch);
    }
示例#4
0
        private void Init(bool isEditor = false)
        {
            if (_isInitialized)
            {
                return;
            }

            _eventsMap      = GetComponent <Tilemap>();
            _lastMapBounds  = _eventsMap.cellBounds;
            _eventsRenderer = GetComponent <TilemapRenderer>();

            // エディターじゃない場合は隠す
            if (!isEditor)
            {
                _eventsRenderer.sortingLayerName = "Default";
                _eventsRenderer.sortingOrder     = -9999;
            }

            _eventsCollider = GetComponent <TilemapCollider2D>();

            // イベントマップがプレイヤーの移動をブロックしなくなる
            _eventsCollider.isTrigger = true;

            _isInitialized = true;
        }
示例#5
0
    // Start is called before the first frame update
    void Start()
    {
        WorldOneRenderer = WorldOne.GetComponent <Renderer>();

        worldTwoRenderer = worldTwo.GetComponent <Renderer>();

        worldTwoRenderer.material.SetFloat("_EffectAmount", 1f);
        worldTwoRenderer.material.SetFloat("_AlphaAmount", 0.5f);

        worldTwoCollidor = worldTwo.GetComponent <TilemapCollider2D>();

        worldOneCollidor = WorldOne.GetComponent <TilemapCollider2D>();


        worldTwoCollidor.enabled = false;
        worldOneCollidor.enabled = true;

        WorldOneHidden = false;

        foreach (Transform child in worldTwo.transform)
        {
            BoxCollider2D childrenCollidor = child.GetComponent <BoxCollider2D>();

            if (childrenCollidor != null)
            {
                childrenCollidor.enabled = false;
            }
        }
    }
        private Tilemap CreateNewTilemap(TilemapKey key)
        {
            string     name = key.GetNameFormat(Layer.Type);
            GameObject tilemapGameObject = LayerGameObject.CreateChildGameObject(name);

            /*if (Importer.DeparentInRuntime)
             * {
             *  tilemapGameObject.AddComponent<LDtkDetachChildren>();
             * }*/

            Tilemap tilemap = tilemapGameObject.AddComponent <Tilemap>();


            if (Importer.IntGridValueColorsVisible)
            {
                TilemapRenderer renderer = tilemapGameObject.AddComponent <TilemapRenderer>();
                renderer.sortingOrder = SortingOrder.SortingOrderValue;
            }

            TilemapCollider2D collider = tilemapGameObject.AddComponent <TilemapCollider2D>();

            if (Importer.UseCompositeCollider)
            {
                Rigidbody2D rb = tilemapGameObject.AddComponent <Rigidbody2D>();
                rb.bodyType = RigidbodyType2D.Static;

                CompositeCollider2D composite = tilemapGameObject.AddComponent <CompositeCollider2D>();
                collider.usedByComposite = true;
            }

            return(tilemap);
        }
示例#7
0
    // Start is called before the first frame update
    void Start()
    {
        joystick = FindObjectOfType <Joystick>();

        sr    = GetComponent <SpriteRenderer>();
        animr = GetComponent <Animator>();
        rb    = GetComponent <Rigidbody2D>();
        cap   = GetComponent <CapsuleCollider2D>();

        health = maxHealth;

        recallPoint = transform.position;

        //muzzle = GetComponentInChildren<Transform>();

        foreach (TilemapCollider2D t in FindObjectsOfType <TilemapCollider2D>())
        {
            if (t.gameObject.CompareTag("Ground"))
            {
                ground = t;
            }
            if (t.CompareTag("UpRamp"))
            {
                ramps = t;
            }
        }
    }
示例#8
0
 // Use this for initialization
 void Start()
 {
     audioSource        = GetComponent <AudioSource>();
     audioSource.clip   = backgroundSong;
     audioSource.volume = 0.1f;
     audioSource.Play();
     reloadingScene      = false;
     forcaPulo           = aceleracao * GetComponent <Rigidbody2D>().mass;
     actualScene         = SceneManager.GetActiveScene();
     this.rigibody       = GetComponent <Rigidbody2D>();
     this.spriteRenderer = GetComponent <SpriteRenderer>();
     PlayerProperties.collideMushroom.AddListener(collideMushroom);
     PlayerProperties.collideEnemy.AddListener(collideEnemy);
     PlayerProperties.dead.AddListener(dead);
     PlayerProperties.loseLifeBlink.AddListener(loseLife);
     PlayerProperties.gainLifeBlink.AddListener(gainLife);
     PlayerProperties.eatFood.AddListener(eatingFood);
     PlayerProperties.jump.AddListener(jump);
     PlayerProperties.win.AddListener(win);
     animator         = GetComponent <Animator>();
     platformCollider = ground.GetComponent <TilemapCollider2D>();
     distToGround     = platformCollider.bounds.extents.y;
     if (yesButton != null)
     {
         yesButton.onClick.AddListener(yesClick);
     }
     if (noButton != null)
     {
         noButton.onClick.AddListener(noClick);
     }
 }
示例#9
0
    /// <summary>
    ///
    /// </summary>
    private void GenerateWallTiles()
    {
        for (int x = 0; x < bounds.width; x++)
        {
            for (int y = 0; y < bounds.height; y++)
            {
                switch (m_map[x, y])
                {
                case 0:
                    dungeonWallsTilemap.SetTile(new Vector3Int(x, y, 0), tiles[0]);
                    break;

                case 1:
                    dungeonSpacesTilemap.SetTile(new Vector3Int(x, y, 0), tiles[1]);
                    break;

                default:
                    break;
                }
            }
        }

        TilemapCollider2D collider2D = dungeonWallsTilemap.gameObject.GetComponent <TilemapCollider2D>();

        if (collider2D == null)
        {
            collider2D = dungeonWallsTilemap.gameObject.AddComponent <TilemapCollider2D>();
        }
    }
示例#10
0
    private void OnLevelChange(Scene scene, LoadSceneMode mode)
    {
        IsGameStarted  = true;
        m_creatureList = FindObjectsOfType <Creature>();
        m_enemy_list   = FindObjectsOfType <Enemy>();

        tilemap = GetComponent <TilemapCollider2D>();

        m_menu = FindObjectOfType <UIMenu>();

        GameObject start = GameObject.FindGameObjectWithTag("start");

        Player.Reset(start.transform.position);

        foreach (var creature in m_creatureList)
        {
            creature.SetupOnStart(this);
        }

        if (m_menu != null)
        {
            m_menu.SetupOnStart(this);

            m_menu.StartGame();
        }
    }
示例#11
0
    void Start()
    {
        animatorSwitch = gameObject.GetComponent <Animator>();
        animatorSwitch.SetBool("IsInitialOn", isOn);
        animatorSwitch.SetBool("IsOn", isOn);
        audioVolumeGlobal = PlayerPrefs.GetInt("VolumeEffects", 75);
        SpriteRenderer rend = gameObject.GetComponent <SpriteRenderer>();

        if (keyColor == MyColors.blue)
        {
            rend.color = new Color(0.2787469f, 0.3286503f, 0.6792453f);
            colorName  = "blue";
        }
        else if (keyColor == MyColors.green)
        {
            rend.color = new Color(0.3907071f, 0.8396226f, 0.384167f);
            colorName  = "green";
        }
        else if (keyColor == MyColors.red)
        {
            rend.color = new Color(0.7075472f, 0.3037113f, 0.3076654f);
            colorName  = "red";
        }

        tilemapRenderer   = associatedTilemapOn.GetComponent <TilemapRenderer>();
        tilemapCollider2D = associatedTilemapOn.GetComponent <TilemapCollider2D>();
        spriteRenderer    = gameObject.GetComponent <SpriteRenderer>();
        audioSource       = gameObject.GetComponent <AudioSource>();
        SwitchRender(true);
    }
示例#12
0
 void OnTriggerEnter2D(TilemapCollider2D other)
 {
     collided = true;
     Destroy(transform.GetChild(0).gameObject);
     GetComponent <BoxCollider2D>().enabled = false;
     GetComponent <Animator>().SetTrigger("Explode");
 }
示例#13
0
        public override void Initialize()
        {
            base.Initialize();

            if (UpdateProperties() == false)
            {
                return;
            }

            Tilemap tilemap2D = properties.tilemap;

            TilemapCollider2D tilemapCollider = gameObject.GetComponent <TilemapCollider2D>();

            if (tilemapCollider != null)
            {
                properties.colliderOffset = tilemapCollider.offset;
            }

            properties.cellAnchor += properties.colliderOffset;

            InitializeGrid();
            InitializeCompositeCollider();

            chunkManager.Update(mapTiles, this);
        }
 void Start()
 {
     AtlasEventManager.Instance.onFlagSet += onFlagSet;
     tilemap = GetComponent <TilemapRenderer>();
     col     = GetComponent <TilemapCollider2D>();
     setVisible();
 }
    // Start is called before the first frame update
    void Start()
    {
        rb  = GetComponent <Rigidbody2D>();
        box = GetComponent <BoxCollider2D>();

        foreach (TilemapCollider2D t in FindObjectsOfType <TilemapCollider2D>())
        {
            if (t.gameObject.CompareTag("Ground"))
            {
                ground = t;
            }
            if (t.CompareTag("UpRamp"))
            {
                ramps = t;
            }
        }

        down = new Vector2(0, -1);

        if (xForce > 0)
        {
            transform.localScale = new Vector3(-1, 1, 1);
        }
        else
        {
            transform.localScale = new Vector3(1, 1, 1);
        }

        player      = FindObjectOfType <Player>().gameObject;
        rb.velocity = new Vector2(xForce, 0);
    }
    // Start is called before the first frame update
    void Awake()
    {
        AstarPath pth = gameObject.AddComponent <AstarPath>();

        pth.logPathResults = PathLog.OnlyErrors;
        wallMap            = mapHolder.GetComponent <Tilemap>();
        coll = mapHolder.GetComponent <TilemapCollider2D>();
    }
示例#17
0
 private void Awake()
 {
     timelineChangedEventChannel = Finder.TimelineChangedEventChannel;
     tilemap           = GetComponent <Tilemap>();
     tilemapCollider2D = GetComponent <TilemapCollider2D>();
     originalColor     = tilemap.color;
     ghostColor        = new Color(originalColor.r, originalColor.g, originalColor.b, ALPHA_OF_COLOR);
 }
示例#18
0
    public static TileBase GetTileFromCollider(TilemapCollider2D col, Vector2 point)
    {
        var tileMap = col.GetComponent <Tilemap>();
        var grid    = tileMap.layoutGrid;
        var pos     = grid.WorldToCell(point);

        return(tileMap.GetTile(pos));
    }
    // Use this for initialization
    void Start()
    {
        tc2d = GetComponent <TilemapCollider2D>();
        tmr  = GetComponent <TilemapRenderer>();

        bossScript = GameObject.FindGameObjectWithTag("FinalBoss").GetComponent <FinalBossScript>();

        camera = Camera.main.gameObject.GetComponent <CameraScript>();
    }
示例#20
0
文件: Chunk.cs 项目: m3stash/Anatema
    private void InitColliders()
    {
        tc2d         = GetComponentInChildren <TilemapCollider2D>();
        tc2d.enabled = false;
        var bc2d = GetComponentInChildren <BoxCollider2D>();

        bc2d.offset = new Vector2(chunkSize / 2, chunkSize / 2);
        bc2d.size   = new Vector2(chunkSize, chunkSize);
    }
示例#21
0
    public void InitTileMap()
    {
        map         = this.gameObject.GetComponent <Tilemap>();
        tile        = Resources.Load <Tile>(TileName);
        mapCollider = new TilemapCollider2D();

        mapCollider           = this.gameObject.AddComponent <TilemapCollider2D>() as TilemapCollider2D;
        mapCollider.isTrigger = true;
    }
示例#22
0
    void Start()
    {
        GameObject gameObject = GameObject.Find("GameMode");

        instance = gameObject.GetComponent <GameMode>();

        body      = GetComponent <Rigidbody2D>();
        tCollider = GetComponent <TilemapCollider2D>();
    }
示例#23
0
 public static void LoadSerializeHashtable(this TilemapCollider2D self, Hashtable hashtble)
 {
     self.maximumTileChangeCount = hashtble.Get <uint>(StringConst.String_maximumTileChangeCount);
     self.extrusionFactor        = hashtble.Get <float>(StringConst.String_extrusionFactor);
     self.isTrigger       = hashtble.Get <bool>(StringConst.String_isTrigger);
     self.usedByEffector  = hashtble.Get <bool>(StringConst.String_usedByEffector);
     self.usedByComposite = hashtble.Get <bool>(StringConst.String_usedByComposite);
     self.offset          = hashtble.Get <string>(StringConst.String_offset).ToVector2OrDefault();
 }
 void Awake()
 {
     flyOverLayer  = GameObject.Find("GroundBlockingLayer");
     surfOverLayer = GameObject.Find("Water");
     flyOverTiles  = flyOverLayer.GetComponent <TilemapCollider2D>();
     surfOverTiles = surfOverLayer.GetComponent <TilemapCollider2D>();
     displayScript = GetComponent <DisplayManager>();
     boxCollider   = GetComponent <BoxCollider2D>();
     waitScript    = GetComponent <WaitManager>();
 }
示例#25
0
    void Start()
    {
        tilemap      = GetComponent <Tilemap>();
        tileCollider = GetComponent <TilemapCollider2D>();

        //Debug.Log(tilemap.cellBounds);

        BoomMapEngine.Instance.RegisterStartGameCallback(RecoverMap);
        BoomMapEngine.Instance.RegisterGameOverCallback(OnGameOver);
    }
示例#26
0
 private void CreatePhysics()
 {
     body          = roomLayer.AddComponent <Rigidbody2D>();
     body.bodyType = RigidbodyType2D.Static;
     cCollider     = roomLayer.AddComponent <CompositeCollider2D>();
     tCollider     = roomLayer.AddComponent <TilemapCollider2D>();
     roomLayer.AddComponent <Grounded>();
     tCollider.usedByComposite = true;
     cCollider.geometryType    = CompositeCollider2D.GeometryType.Polygons;
 }
示例#27
0
 void Start()
 {
     tr  = GetComponent <TilemapRenderer>();
     box = GetComponent <TilemapCollider2D>();
     PlayerControl1.Instance.swap.OnSwap += HandleSwap;
     if (!worldOne)
     {
         Hide();
     }
 }
    private void SetTilemapVisibility(bool enabled)
    {
        TilemapCollider2D collider = GetComponent <TilemapCollider2D>();

        if (collider != null)
        {
            collider.enabled = enabled;
        }

        GetComponent <TilemapRenderer>().enabled = enabled;
    }
    //Problemas: Se desrenderizan todos los edificios -> los edificios a los que se pueda entrar tienen que ir en un tilemap / spriterenderer aparte
    //Añadir: Oscurecer el resto del mundo
    private void changeRoom()
    {
        t1.enabled = !t1.enabled;
        t2.enabled = !t2.enabled;
        TilemapCollider2D t = t1.gameObject.GetComponent <TilemapCollider2D>();

        if (t != null)
        {
            t.enabled = !t.enabled;
        }
    }
示例#30
0
文件: Penek.cs 项目: jhzII/goldensoul
 void Start()
 {
     Player = GameObject.FindGameObjectWithTag("Player");
     Rigi   = GetComponent <Rigidbody2D>();
     Anim   = GetComponent <Animator>();
     Col    = GetComponent <BoxCollider2D>();
     Anim.SetBool("Attack", false);
     TC1 = GameObject.Find("solidmiddle").GetComponent <TilemapCollider2D>();
     TC2 = GameObject.Find("solidbottom").GetComponent <TilemapCollider2D>();
     TC3 = GameObject.Find("solidbottom2").GetComponent <TilemapCollider2D>();
 }