// Use this for initialization void Start() { // Get pieces track = transform.parent.GetChild(1).gameObject.GetComponent <tk2dSprite>(); // Calculate useful values minX = track.GetComponent <Renderer>().bounds.min.x; maxX = track.GetComponent <Renderer>().bounds.max.x; length = maxX - minX; snap = length / ((Maximum - Minimum) / Snap); // Set initial value SetValue(Value); }
private void restart() { if (isRestart == false) { isRestart = true; spriteResume.GetComponent <Renderer>().enabled = false; spriteRetry.GetComponent <Renderer>().enabled = false; spriteMainMenu.GetComponent <Renderer>().enabled = false; spriteMute.GetComponent <Renderer>().enabled = false; spriteRestart.GetComponent <Renderer>().enabled = true; spriteYes.GetComponent <Renderer>().enabled = true; spriteNo.GetComponent <Renderer>().enabled = true; } }
private void LockBase_Changed(LockBase sender) { _opened = sender.isOpened; spriteTop.scale = new Vector3(1f - 0.5f * sender.openingProgress, 1f); spriteTop.GetComponent <Renderer>().enabled = !_opened; }
void BoardReset() { for (int i = 0; i < 30; i++) { //drops[index].renderer.enabled = false; //var component = GetComponent("Drop"); //Destroy(component); drops[i].DeleteDrop(); } int index = 0; for (int i = 0; i < 6; i++) { for (int j = 0; j < 5; j++) { tk2dSprite drop = (tk2dSprite)Instantiate(sprite, new Vector3(i * 2, j * 2, 0), Quaternion.identity); var component = drop.GetComponent <Drop>(); //drops[index] = new Drop(); drops[index] = component; component.Row = i; component.Column = j; component.DropIndex = index++; component.DropColor = (DropColor)UnityEngine.Random.Range(1, 6); } } }
public static bool SpawnerMain_SpawnItemSprite(SpawnerMain __instance, InvItem item, tk2dSprite itemImage, Item newItem) { try { itemImage.SetSprite(__instance.gc.spawnerMain.itemSprites, item.spriteName); } catch { } Material mat = itemImage.CurrentSprite.material; itemImage.GetComponent <Renderer>().sharedMaterial = mat; try { if (!__instance.gc.serverPlayer) { __instance.itemLightUp = Instantiate(mat); __instance.itemLightUp.shader = __instance.gc.lightUpShader; } newItem.objectSprite.sprH.GetComponent <Renderer>().sharedMaterial = mat; newItem.objectSprite.sprH.SetSprite(itemImage.spriteId); } catch { try { try { newItem.objectSprite.GetComponent <Renderer>().sharedMaterial = mat; } catch { Debug.LogError("Couldn't set highlight for item 1: " + newItem); } try { newItem.objectSprite.spr.GetComponent <Renderer>().sharedMaterial = mat; } catch { Debug.LogError("Couldn't set highlight for item 2: " + newItem); } try { newItem.objectSprite.sprH.GetComponent <Renderer>().sharedMaterial = mat; } catch { Debug.LogError("Couldn't set highlight for item 3: " + newItem); } newItem.objectSprite.transform.Find("Highlight").GetComponent <tk2dSprite>().SetSprite(itemImage.spriteId); Debug.LogError("SPAWNN"); } catch { Debug.LogError("Couldn't set highlight for item 4: " + newItem); } } if (item.invItemName == VanillaItems.Money) { if (item.invItemCount is 1) { itemImage.SetSprite(itemImage.GetSpriteIdByName("MoneyA")); item.shadowOffset = 6; } else if (item.invItemCount > 1 && item.invItemCount <= 5) { itemImage.SetSprite(itemImage.GetSpriteIdByName("MoneyB")); item.shadowOffset = 4; } else if (item.invItemCount > 5 && item.invItemCount < 10) { itemImage.SetSprite(itemImage.GetSpriteIdByName("MoneyC")); item.shadowOffset = 4; } else { item.shadowOffset = 3; } } return(false); }
public static void SpawnerMain_SpawnItemWeapon(Item __result) { try { tk2dSprite itemImage = __result.tr.GetChild(0).transform.GetChild(0).GetComponent <tk2dSprite>(); itemImage.GetComponent <Renderer>().sharedMaterial = itemImage.CurrentSprite.material; } catch { } }
void OnTriggerEnter2D(Collider2D collider) { // If we've collided with the player then fire an event to let the player know! Also let's take away some health for the enemy if (collider.tag == "Player") { _isAlive = false; float damageValue = 1f - (float)(_settingsModified.Health - 1) / (float)_settings.Health; float boost = Mathf.Lerp(0.5f, 1f, damageValue); _rb.gravityScale = 0.75f; Vector2 vel = GameController.Instance.Player.GetVelocity(); vel.x *= 1.25f; vel.y = GameSettings.Instance.DamageSettings.Boost * 0.5f; _rb.velocity = Vector2.zero; _rb.AddForce(vel, ForceMode2D.Impulse); _sprite.SetSprite("Bird_Dead"); VisualUtils.AddHit(this.transform.position); GameController.Instance.PlaySound(GameSettings.Instance.AudioSettings.Smash, 1f, damageValue + 1f); if (--_settingsModified.Health <= 0) { Explode(); GameController.Instance.PlaySound(GameSettings.Instance.AudioSettings.Death); GameController.Instance.OnPlayerBoost(Vector3.up, boost * 1.25f); } else { _sprite.color = Color.Lerp(Color.white, Color.red, damageValue); GameController.Instance.Camera.Screenshake(0.25f, 0.5f); GameController.Instance.OnPlayerBoost(Vector3.up, boost); // On the first hit let's stop bird's flying animation _sprite.GetComponent <tk2dSpriteAnimator>().Stop(); // Also let's add goggles GameObject go = GameObject.Instantiate(GameSettings.Instance.Prefabs.Bone, this.transform.position, Quaternion.AngleAxis(Random.value * 360f, Vector3.forward)) as GameObject; Rigidbody2D boneRigidbody = go.GetComponent <Rigidbody2D>(); Vector2 explodeVel = new Vector2(Random.Range(-5f, 5f), 10f); boneRigidbody.AddForce(explodeVel, ForceMode2D.Impulse); boneRigidbody.angularVelocity = 0.0f; boneRigidbody.AddTorque(-boneRigidbody.velocity.x * 0.5f, ForceMode2D.Impulse); } } }
void Start() { if (Prefab_FishLockabe == null) { Fish[] prefabAllFish = GameMain.Singleton.FishGenerator.Prefab_FishAll; List <Fish> tmpLst = new List <Fish>(); foreach (Fish f in prefabAllFish) { if (f.IsLockable) { tmpLst.Add(f); } } Prefab_FishLockabe = tmpLst.ToArray(); } mTs = transform; mPlayer = GetComponent <Player>(); mDepth = Defines.GlobleDepth_PlayerTargeter + 0.001F * mPlayer.Idx;//����idx����δ��ʼ���� if (GameMain.Singleton.IsScreenNet() && GameMain.Singleton.BSSetting.IsBulletCrossWhenScreenNet.Val) { mChangeTargetArea = GameMain.Singleton.WorldDimension; } else { mChangeTargetArea = mPlayer.AtScreenArea; } mStartLockArea = mPlayer.AtScreenArea; Spr_TargetMoving.spriteId = Spr_TargetMoving.GetSpriteIdByName(NameSprTargetMoving + mPlayer.Idx % 10); Spr_Target.spriteId = Spr_Target.GetSpriteIdByName(NameSprTarget + mPlayer.Idx % 10); Spr_TargetMoving.GetComponent <Renderer>().enabled = false; Spr_Target.GetComponent <Renderer>().enabled = false; }
static void DoCreateSpriteObject() { tk2dSpriteGuiUtility.GetSpriteCollectionAndCreate((sprColl) => { GameObject go = tk2dEditorUtility.CreateGameObjectInScene("Sprite"); tk2dSprite sprite = go.AddComponent <tk2dSprite>(); sprite.SetSprite(sprColl, sprColl.FirstValidDefinitionIndex); sprite.GetComponent <Renderer>().material = sprColl.FirstValidDefinition.material; sprite.Build(); Selection.activeGameObject = go; Undo.RegisterCreatedObjectUndo(go, "Create Sprite"); }); }
void DoGameOver() { TransitionIn.Play(); Cover.GetComponent <Renderer>().enabled = true; Cursor.GetComponent <Renderer>().enabled = false; GameOverScreen.Translate(0, 0, VisibleZ - GameOverScreen.position.z); ScoreText.text = SixthsGameState.Score.ToString(); ScoreText.Commit(); // Handle high score highScore = PlayerPrefs.GetInt(HighScorePrefsKey, 0); if (SixthsGameState.Score > highScore) { highScore = SixthsGameState.Score; PlayerPrefs.SetInt(HighScorePrefsKey, highScore); PlayerPrefs.Save(); } HighScoreText.text = highScore.ToString(); HighScoreText.Commit(); SixthsGameState.GameRunning = false; }
public void Initialize(tk2dSprite sprite, float duration, float alpha) { if (this.Sprite == null) { _sprite = tk2dSprite.AddComponent(this.gameObject, sprite.Collection, sprite.spriteId); _sprite.GetComponent <MeshRenderer>().sortingOrder = sprite.GetComponent <MeshRenderer>().sortingOrder - 1; _sprite.GetComponent <MeshRenderer>().sortingLayerID = sprite.GetComponent <MeshRenderer>().sortingLayerID; } else { _sprite.SetSprite(sprite.spriteId); } _alpha = alpha; Color color = sprite.color; color.a = _alpha; _sprite.color = color; _duration = duration; _originalPosition = sprite.transform.position; transform.position = _originalPosition; _originalScale = sprite.transform.localScale; transform.localScale = _originalScale; _originalRotation = sprite.transform.localRotation; transform.localRotation = _originalRotation; _initialized = true; gameObject.SetActive(true); StartCoroutine(RunProcessor()); }
/// <summary> /// Let's attach a tk2d sprite. /// </summary> /// <param name="targetGameObject">The game object to attach to.</param> public void AttachTk2dSprite(GameObject targetGameObject, tk2dSpriteCollectionData spriteCollectionData) { // sanity. if (targetGameObject == null || tk2dSpriteName == null || spriteCollectionData == null) { return; } // triple check the sprite definitions... this is madness... this is SPARTA! List <tk2dSpriteDefinition> spriteDefinitions = new List <tk2dSpriteDefinition>(spriteCollectionData.spriteDefinitions); tk2dSpriteDefinition spriteDef = spriteDefinitions.Find(each => each.name == tk2dSpriteName); if (spriteDef == null || spriteDef.name == "") { // this condition should never happen because we're finding the definition by name... // if we do trip it up, then, at least don't die a horrible death. return; } // lookup the index int spriteIndex = spriteDefinitions.IndexOf(spriteDef); // create a tk2dsprite tk2dSprite spriteComponent = targetGameObject.AddComponent <tk2dSprite>() as tk2dSprite; // set the sprite based on the index because it's safer that way... :( spriteComponent.SetSprite(spriteCollectionData, spriteIndex); // update the sorting layer spriteComponent.GetComponent <Renderer>().sortingLayerName = sortingLayerName; spriteComponent.SortingOrder = sortingOrder; spriteComponent.Build(); // set visibility spriteComponent.GetComponent <Renderer>().enabled = isVisible; }
static void DoCreateSpriteObject() { tk2dSpriteCollectionData sprColl = null; if (sprColl == null) { // try to inherit from other Sprites in scene tk2dSprite spr = GameObject.FindObjectOfType(typeof(tk2dSprite)) as tk2dSprite; if (spr) { sprColl = spr.Collection; } } if (sprColl == null) { tk2dSpriteCollectionIndex[] spriteCollections = tk2dEditorUtility.GetOrCreateIndex().GetSpriteCollectionIndex(); foreach (var v in spriteCollections) { GameObject scgo = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(v.spriteCollectionDataGUID), typeof(GameObject)) as GameObject; var sc = scgo.GetComponent <tk2dSpriteCollectionData>(); if (sc != null && sc.spriteDefinitions != null && sc.spriteDefinitions.Length > 0 && !sc.managedSpriteCollection) { sprColl = sc; break; } } if (sprColl == null) { EditorUtility.DisplayDialog("Create Sprite", "Unable to create sprite as no SpriteCollections have been found.", "Ok"); return; } } GameObject go = tk2dEditorUtility.CreateGameObjectInScene("Sprite"); tk2dSprite sprite = go.AddComponent <tk2dSprite>(); sprite.SwitchCollectionAndSprite(sprColl, sprColl.FirstValidDefinitionIndex); sprite.GetComponent <Renderer>().material = sprColl.FirstValidDefinition.material; sprite.Build(); Selection.activeGameObject = go; Undo.RegisterCreatedObjectUndo(go, "Create Sprite"); }
void Start() { // Let's get the player settings from our game settings _settings = GameSettings.Instance.PlayerSettings; // Register to game events GameController.Instance.OnPlayerBoost += Boost; GameController.Instance.OnPlayerInputBlocked += (bool blocked) => { _isInputBlocked = blocked; }; GameController.Instance.OnPlayerSetVisible += (bool visible) => { _sprite.GetComponent <MeshRenderer>().enabled = visible; }; InputController.OnTouchBegan += TouchBegan; InputController.OnTouchEnded += TouchEnded; // We'll add the initial jump to get the game started Jump(Vector2.up); // Find the current player skin prefix for the sprites _playerSkinPrefix = string.Format("Player0{0}", _settings.SkinIdx); }
void setBulletDirection() { Vector3 axisX = new Vector3(1, 0, 0); Vector3 bulletDirection = getDirection(); crossDirection = getCrossDirection(bulletDirection); Vector3 angle = new Vector3(0, 0, angle_360(new Vector3(1, 0, 0), bulletDirection)); //Debug.Log ("子弹和X轴角度: " + angle); bulletSprite.transform.Rotate(angle); if (getShadow) { shadowSprite.scale = new Vector3(bulletSprite.scale.x * 0.9f, bulletSprite.scale.y * 0.7f, bulletSprite.scale.z); shadowSprite.GetComponent <shadowAniManager> ().shadowRotate(angle); } if (bulletDie == false) { flying(); } }
//public int count{get;set;} IEnumerator GenerateUnits(List <List <Drop> > scanlist) { int combo = scanlist.Count; DispCombo.Count = combo; for (int i = 0; i < combo; i++) { //yield return new WaitForSeconds(1.5f); Debug.Log("count : " + i + " combo : " + scanlist.Count); tk2dSprite unit = (tk2dSprite)Instantiate(unitprefab, new Vector3(2f, 10.8f, 3f), Quaternion.identity); var component = unit.GetComponent <Unit>(); component.SetUnit((int)scanlist[i][0].DropColor, scanlist[i].Count, combo); GameObject ground = GameObject.FindWithTag("Ground"); var pos = ground.transform; component.transform.Translate(pos.localPosition.x - 6.718847f, 0f, 0f); component.transform.parent = ground.transform; unitlist.Add(component); yield return(new WaitForSeconds(1.5f)); } scanlist.Clear(); }
// Use this for initialization void Awake() { Player_FishLocker fishLocker = GetComponent <Player_FishLocker>(); fishLocker.EvtTargetOnFish += Handler_TargetOnFish; fishLocker.EvtTargetLeaveFish += Handler_TargetLeavefish; mSprCard = Instantiate(Prefab_Card) as tk2dSprite; mTsCard = mSprCard.transform; mRdCard = mSprCard.GetComponent <Renderer>(); mTsCard.parent = transform; mTsCard.localRotation = Quaternion.identity; mRdCard.enabled = false; mFishTypeIdToCard = new Dictionary <int, string>(); foreach (FishRelateCard fc in FishAndCard) { mFishTypeIdToCard.Add(fc.Prefab.TypeIndex, fc.SprName); } }
// Use this for initialization void Start() { color[0] = new Color(1.0f, 0.2f, 0.2f, 1.0f); color[1] = new Color(0.2f, 1.0f, 0.2f, 1.0f); color[2] = new Color(0.2f, 0.2f, 1.0f, 1.0f); color[3] = new Color(1.0f, 1.0f, 0.2f, 1.0f); color[4] = new Color(0.9f, 0.9f, 0.9f, 1.0f); int index = 0; for (int i = 0; i < 6; i++) { for (int j = 0; j < 5; j++) { tk2dSprite drop = (tk2dSprite)Instantiate(sprite, new Vector3(i * 2, j * 2, 0), Quaternion.identity); var component = drop.GetComponent <Drop>(); drops[index] = component; component.Row = i; component.Column = j; component.DropIndex = index++; component.DropColor = (DropColor)UnityEngine.Random.Range(1, 6); } } }
void Start() { /*if(GlobalVariableManager.Instance.characterUpgradeArray[1][18] == 'o'){ * //pin perk 5 - every pin costs one less pp to equip * if(pinData.price > 1){ * pinData.price -= 1; * }else{ * pinData.price = 1; * } * }*/ myAnimator = sprite.GetComponent <Animator>(); mySFX = sprite.GetComponent <SpecialEffectsBehavior>(); player = GameObject.Find("Jim"); // Default the new pin to "off". newPinIcon.SetActive(false); if (inShop) { inShop = true; } else { if (!IsPinDiscovered()) { sprite.color = new Color(0f, 0f, 0f, 1f);//blacked out if not owned } else { for (int i = 0; i < pinData.ppValue; i++) { smallPPIcons.transform.GetChild(i).gameObject.SetActive(true); if (IsPinEquipped()) { smallPPIcons.transform.GetChild(i).gameObject.GetComponent <SpriteRenderer>().color = Color.white; } } if (pinData.abilityPin == true) { GameObject abilityPS = ObjectPool.Instance.GetPooledObject("effect_AbilityPin", gameObject.transform.position); abilityPS.transform.parent = this.transform; } if (!IsPinViewed()) { newPinIcon.SetActive(true); } } for (int i = 0; i < pinData.ppValue; i++) { myIcons.Add(smallPPIcons.transform.GetChild(i).gameObject); } } /* if (inShop){ * if(IsPinDiscovered() && GlobalVariableManager.Instance.MENU_SELECT_STAGE != 10 && GlobalVariableManager.Instance.MENU_SELECT_STAGE != 20 && GlobalVariableManager.Instance.MENU_SELECT_STAGE != 30){ * GameObject myTextDisplay = Instantiate(smallTextDisplay,transform.position,Quaternion.identity); * Color currentColor = sprite.color; * sprite.color = new Color(currentColor.r,currentColor.g,currentColor.b,.4f);//fade * myTextDisplay.GetComponent<tk2dSprite>().SetSprite(soldTextSprite); * bought = true; * } * * startingY = gameObject.transform.position.y; * }//end of inShop Check*/ }
// Update is called once per frame void Update() { if (Input.GetMouseButton(0)) { for (int i = 0; i < 30; i++) { int xaxis = (int)System.Math.Round(drops[i].transform.position.x / drops[i].dropSize); int yaxis = (int)System.Math.Round(drops[i].transform.position.y / drops[i].dropSize); //ドロップのはみ出しを抑制 if (xaxis >= 5) { xaxis = 5; } if (yaxis >= 4) { yaxis = 4; } if (xaxis <= 0) { xaxis = 0; } if (yaxis <= 0) { yaxis = 0; } //ドロップ操作 if (drops[i].Dragging == true) { //Debug.Log(i.ToString() +" " +xaxis.ToString()+", "+yaxis.ToString() + " row : " // + drops[i].Row + " column : " + drops[i].Column); if (drops[i].Row != xaxis || drops[i].Column != yaxis) { int j; for (j = 0; j < 30; j++) { if (drops[j].Row == xaxis && drops[j].Column == yaxis) { break; } } drops[j].Row = drops[i].Row; drops[j].Column = drops[i].Column; drops[i].Row = xaxis; drops[i].Column = yaxis; } } } } var vec = Input.mousePosition; vec.z = 0; var worldPosition = Camera.main.ScreenToWorldPoint(vec); if (Input.GetMouseButtonDown(0)) { Debug.Log(vec); } //マウスが離されたらmatch3判定 if (Input.GetMouseButtonUp(0) && vec.y < 353) { Drop[,] board = new Drop[6, 5]; for (int i = 0; i < 30; i++) { board[drops[i].Row, drops[i].Column] = drops[i]; } scan(board); BoardReset(); } timer += Time.deltaTime; if (timer > 1f) { tk2dSprite unit = (tk2dSprite)Instantiate(enemyprefab, new Vector3(30f, 11.5f, 3f), Quaternion.identity); var component = unit.GetComponent <Enemy>(); GameObject ground = GameObject.FindWithTag("Ground"); var pos = ground.transform; component.transform.Translate(pos.localPosition.x - 6.718847f, 0f, 0f); component.transform.parent = ground.transform; timer = 0f; } }
virtual public void ShowStuffOnShelf() // 처음시작시, 게임끝난후. 호출. { int state = SaveManager.GetCollectionStatesInCategory(category); MS = (MissionState)state; string stuffSpriteName = ""; int unlocked = SaveManager.GetCollectionUnlockedInCategory(category); if (MS != MissionState.Complete) { missionBG.SetActive(true); complete.SetActive(false); ShowLocalizeNumbers(); } infoBtnAnim.Stop(); infoBtnAnim.gameObject.transform.localScale = new Vector3(1f, 1f, 1f); stuffOnShelf.GetComponent <Animation>().Stop(); stuffOnShelf.transform.localScale = new Vector3(1f, 1f, 1f); //애니메이션이 scale을 왔다갔다 하므로. SetInfoBtn(); if (unlocked == 0) // 초기 세팅-비어있는 공간으로 표시. { if (state == 3) //성공상태. { ShowSuccessStamp(); stuffOnShelf.GetComponent <Renderer>().enabled = true; stuffOnShelf.SetSprite("collection_box" + boxSize.ToString()); stuffOnShelf.GetComponent <Animation>().Play("newBoxIdle"); } else if (state == 2) { ShowFailedStamp(); stuffOnShelf.GetComponent <Renderer>().enabled = false; } else { ShowStampOff(); stuffOnShelf.GetComponent <Renderer>().enabled = false; } } else { stuffOnShelf.GetComponent <Renderer>().enabled = true; switch (state) { case 0: ShowStampOff(); //start 이전. stuffSpriteName = "collection_icon" + (category + 1).ToString("D2") + "_" + (unlocked).ToString(); break; case 1: // ongoing 중. ShowStampOff(); if (MT == MissionType.Conditioned) { } stuffSpriteName = "collection_icon" + (category + 1).ToString("D2") + "_" + (unlocked).ToString(); break; case 2: // failed. ShowFailedStamp(); stuffSpriteName = "collection_icon" + (category + 1).ToString("D2") + "_" + (unlocked).ToString(); break; case 3: // success. ShowSuccessStamp(); stuffSpriteName = "collection_box" + boxSize.ToString(); stuffOnShelf.GetComponent <Animation>().Play("newBoxIdle"); break; case 4: //complete. ShowStampOff(); missionBG.SetActive(false); complete.SetActive(true); stuffSpriteName = "collection_icon" + (category + 1).ToString("D2") + "_" + (unlocked).ToString(); break; } stuffOnShelf.SetSprite(stuffSpriteName); } }