// 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); }
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; }
// 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); }
// 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; } } }
// 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); } }
/// <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>(); } }
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(); } }
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); }
void OnTriggerEnter2D(TilemapCollider2D other) { collided = true; Destroy(transform.GetChild(0).gameObject); GetComponent <BoxCollider2D>().enabled = false; GetComponent <Animator>().SetTrigger("Explode"); }
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>(); }
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); }
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>(); }
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); }
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; }
void Start() { GameObject gameObject = GameObject.Find("GameMode"); instance = gameObject.GetComponent <GameMode>(); body = GetComponent <Rigidbody2D>(); tCollider = GetComponent <TilemapCollider2D>(); }
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>(); }
void Start() { tilemap = GetComponent <Tilemap>(); tileCollider = GetComponent <TilemapCollider2D>(); //Debug.Log(tilemap.cellBounds); BoomMapEngine.Instance.RegisterStartGameCallback(RecoverMap); BoomMapEngine.Instance.RegisterGameOverCallback(OnGameOver); }
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; }
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; } }
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>(); }