public void StartASkill(Skill skill) { string skillClassName = skill.GetType().ToString(); GameObject user = skill.owner; Debug.Log("SkillManager: " + user.ToString() + " uses skill " + skillClassName); }
public void lue_ehdokas() { //nimi = Ehdokas.ToString(); NaytaEhdokas.GetComponentInChildren <Text>().text = Ehdokas.ToString(); ShowThis.SetActive(true); HideThis.SetActive(false); }
public void StartAItem(Item item) { string itemClassName = item.GetType().ToString(); GameObject user = item.owner; Debug.Log("ItemManager: " + user.ToString() + " uses item " + itemClassName); }
public void RpcSetEnabled(GameObject obj, string class_name, bool enabled) { if (obj) { if (class_name != "Collider" && class_name != "Renderer") { Type t = Type.GetType(class_name); if (t != null) { MonoBehaviour c = obj.GetComponent(t) as MonoBehaviour; c.enabled = enabled; } else { Debug.Log(class_name + obj.ToString()); } } else if (class_name == "Collider") { obj.GetComponent <Collider>().enabled = enabled; } else { obj.GetComponent <Renderer>().enabled = enabled; foreach (Renderer rend in obj.GetComponentsInChildren <Renderer>()) { rend.enabled = enabled; } } } }
/// Allow to select an item in the stage. /// @param item A GameObject containing the item to select. public void SelectItem(GameObject item) { GameObject found = this.FindItem(item); if (found) { Debug.Log("Item Found: " + found.ToString()); if (SelectedItem) { ModelBehaviour model = this.GetModelBehaviour(SelectedItem); if (model) { model.SetSelected(false); model.RotationJoystick = null; model.MovementJoystick = null; } } ModelBehaviour foundModel = this.GetModelBehaviour(found); if (foundModel) { this.SelectedItem = found; foundModel.SetSelected(true); foundModel.RotationJoystick = RotationJoystick; if (ARSession.state == ARSessionState.Unsupported && MovementJoystick) { foundModel.MovementJoystick = MovementJoystick; } this.ActivateSelectedInterface(true); } } }
//Display the focus in the menu private void DisplayCurrentFocus(Being b) { ClearMenu(); if (being.focus.Count == 0) { PopulateFocusList(); } RecoverFocus(); if (being.focus.Count > 0) { for (int ii = 0; ii < being.focus.Count; ii++) { Debug.Log(focusDisplay.ToString()); Debug.Log("being focus count is " + being.focus.Count); Debug.Log("ii is " + ii); //create a focus display UI object GameObject display = GameObject.Instantiate(focusDisplay, content); //set the UI object to that focus token display.GetComponent <FocusTokenDisplay>().Initialize(being.focus[ii]); //space each button out by height display.transform.position = new Vector3(display.transform.position.x, display.transform.position.y - (25 * ii), display.transform.position.z); //display.transform.position = new Vector3(0,0,0); //give the focus token display a reference to a focus token display.GetComponent <FocusTokenDisplay>().focusToken = being.focus[ii]; //Add this focus token display object to the menu focusTargets.Add(display); } } }
public void buttonClicked(GameObject door) { if (door.tag.Contains("Toilet")) { foreach (var sign in SignList) { if (sign.Item1.Contains(door.tag)) { signGO1 = GameObject.Find(sign.Item1); signGO2 = GameObject.Find(sign.Item2); } } signAnimator1 = signGO1.GetComponent <Animator>(); signAnimator2 = signGO2.GetComponent <Animator>(); signAnimator1.SetBool("Fade", false); signAnimator2.SetBool("Fade", false); } else { foreach (string word in WordList) { if (word.Contains(door.tag)) { Debug.Log(word); foreach (var Wobject in WordObjects) { if (string.Equals(Wobject.Item1, word)) { wordGO = Wobject.Item2; Debug.Log("word Object: " + wordGO.ToString()); } } break; } } wordGO.SetActive(true); Debug.Log("word chosen: " + wordGO.ToString()); wordAnimator = wordGO.GetComponent <Animator>(); wordAnimator.SetBool("Fade", false); } foreach (string navigation in NavigationList) { Debug.Log("door.tag = " + door.tag); if (navigation.Contains(door.tag)) { Debug.Log(navigation); foreach (var Nobject in NavigationObjects) { if (string.Equals(Nobject.Item1, navigation)) { navigationGO = Nobject.Item2; Debug.Log("navigation Object: " + navigationGO.ToString()); } } break; } } door.GetComponent <Renderer>().material.color = Color.green; navigationGO.SetActive(true); }
/// <summary> /// 実際に動く経路を評価する /// </summary> public void assessmenttest() { int tmp = searchTarget.Count; if (tmp == 1) { tmp = 0; } else { tmp = tmp - 1; } /* * if (searchTarget == null) { * SearchInit (); * }*/ if (searchTarget [tmp].gameObject.ToString() == GoalPosition.ToString()) { return; } FindGetTargetObject(); assessmenttest(); }
/// <summary> /// Funzione che di Setup /// </summary> public void Setup() { poolDictionary = new Dictionary <ObjectTypes, List <IPoolObject> >(); foreach (PoolObjects obj in poolObjects) { List <IPoolObject> objectsToAdd = new List <IPoolObject>(); for (int i = 0; i < obj.ammount; i++) { GameObject instantiateObject = Instantiate(obj.prefab, transform); IPoolObject instantiateObjectInterface = instantiateObject.GetComponent <IPoolObject>(); if (instantiateObjectInterface != null) { instantiateObjectInterface.OnObjectDestroy += OnObjectDestroy; instantiateObjectInterface.OnObjectSpawn += OnObjectSpawn; OnObjectDestroy(instantiateObjectInterface); objectsToAdd.Add(instantiateObjectInterface); instantiateObjectInterface.PoolInit(); } else { Debug.Log("il prefab: " + instantiateObject.ToString() + " type:" + obj.objectType.ToString() + " non implementa l'interfaccia IPoolObject"); break; } } poolDictionary.Add(obj.objectType, objectsToAdd); } }
public static void Init() { dict.Clear(); /*if (initialized) * return;*/ GameObject lo = Resources.Load <GameObject>("Prefabs/letter"); if (lo != null && lo.ToString().ToLower() != "null") { LETTER_OBJECT = lo; } GameObject bo = Resources.Load <GameObject>("Prefabs/DialogBubble"); if (bo != null && bo.ToString().ToLower() != "null") { BUBBLE_OBJECT = bo; } //string modPath = FileLoader.pathToModFile("Sprites/UI/Fonts"); //string defaultPath = FileLoader.pathToDefaultFile("Sprites/UI/Fonts"); //loadAllFrom(defaultPath); LoadAllFrom(FileLoader.pathToModFile("Sprites/UI/Fonts"), true); //initialized = true; }
/// <summary> /// Finds the gameobject the player is currently looking at, and /// deals with it /// </summary> void PlayerSelectUpdate() { LookObject = PlayerCameraScript.CameraController.GetViewObject(); if (LookObject == null) { DebugGUI.Instance.ClearData("player_view"); //Debug.Log(GUIManager.Instance); //Debug.Log(GUIManager.Instance.IngameGUI); GUIManager.Instance.IngameGUI.SetNPC(null); } else { DebugGUI.Instance.SetData("player_view", LookObject.ToString()); if (LookObject.GetComponent <LoadedEntity>() != null) { if (LookObject.GetComponent <LoadedEntity>().Entity is NPC) { GUIManager.Instance.IngameGUI.SetNPC(LookObject.GetComponent <LoadedEntity>().Entity as NPC); } else { GUIManager.Instance.IngameGUI.SetNPC(null); } } else { GUIManager.Instance.IngameGUI.SetNPC(null); } } WorldLookPosition = PlayerCameraScript.CameraController.GetWorldLookPosition(); DebugGUI.Instance.SetData("look_wpos", WorldLookPosition); }
public int SetDestroyedCube(GameObject toDestroyingCube) { switch (toDestroyingCube.ToString()) { case "DirtCube(Clone) (UnityEngine.GameObject)": destroyedItem = 0; break; case "StoneCube(Clone) (UnityEngine.GameObject)": destroyedItem = 1; break; case "Wooden_PlanksCube(Clone) (UnityEngine.GameObject)": destroyedItem = 2; break; case "Copple_stone(Clone) (UnityEngine.GameObject)": destroyedItem = 3; break; case "Gravel(Clone) (UnityEngine.GameObject)": destroyedItem = 4; break; case "Sand(Clone) (UnityEngine.GameObject)": destroyedItem = 5; break; case "Bedrock(Clone) (UnityEngine.GameObject)": destroyedItem = 6; break; case "Obsidian(Clone) (UnityEngine.GameObject)": destroyedItem = 7; break; case "Brick(Clone) (UnityEngine.GameObject)": destroyedItem = 8; break; } //print (destroyedItem); return destroyedItem; }
public void SpawnItem(Item item, Vector3 position) { Debug.Log("SPAWNING: " + item.ToString()); GameObject gameObject = crown; switch (item) { case Item.Crown: gameObject = crown; break; case Item.Fist: case Item.Claw: case Item.Sword: gameObject = fist; break; case Item.Big_Claw: case Item.Big_Fist: case Item.Big_Sword: gameObject = claw; break; } Debug.Log(gameObject != null); if (gameObject != null) { Debug.Log("object? " + gameObject.ToString()); GameObject obj = Instantiate(gameObject, position, Quaternion.identity); obj.GetComponent <Interactable>().giveItem = item; // obj.transform.position = new Vector3(obj.transform.position.x, -0.1f, obj.transform.position.z); obj.transform.Translate(Random.insideUnitCircle * new Vector3(1, 0, 1)); } }
// Use this for initialization void Start() { Sprite = GetComponent <Sprite>(); //Rend = GetComponent<SpriteRenderer>(); Anim = GetComponent <Animator>(); switch (Parent.ToString()) { case "BossRed (UnityEngine.GameObject)": Anim.SetTrigger("red"); break; case "BossBlue (UnityEngine.GameObject)": Anim.SetTrigger("blue"); break; case "BossYellow (UnityEngine.GameObject)": Anim.SetTrigger("yellow"); break; case "BossPurple (UnityEngine.GameObject)": Anim.SetTrigger("purple"); break; default: Anim.SetTrigger("grey"); break; } }
public UnityPacMan(GameObject g) : base() { _gameObject = g; #if DEBUG this.Log("GameObject" + g.ToString()); #endif }
private void Start() { // 本地玩家与敌方玩家Text初始化 localPlayerUsername = transform.Find("BluePanel/Username").GetComponent <Text>(); localPlayerTotalCount = transform.Find("BluePanel/TotalCount").GetComponent <Text>(); localPlayerWinCount = transform.Find("BluePanel/WinCount").GetComponent <Text>(); enemyPlayerUsername = transform.Find("RedPanel/Username").GetComponent <Text>(); enemyPlayerTotalCount = transform.Find("RedPanel/TotalCount").GetComponent <Text>(); enemyPlayerWinCount = transform.Find("RedPanel/WinCount").GetComponent <Text>(); // 获取敌我面板,开始,退出按钮的引用 bluePanel = transform.Find("BluePanel"); redPanel = transform.Find("RedPanel"); startButton = transform.Find("StartButton"); exitButton = transform.Find("ExitButton"); // 基本信息的方法注册监听 transform.Find("StartButton").GetComponent <Button>().onClick.AddListener(OnStartClick); transform.Find("ExitButton").GetComponent <Button>().onClick.AddListener(OnExitClick); quitRoomRequest = GetComponent <QuitRoomRequest>(); startGameRequest = GetComponent <StartGameRequest>(); EnterAnim(); network = GameObject.Find("NetworkManager"); manager = network.GetComponent <NetworkManager>(); Debug.Log(network.ToString()); }
/// <summary> /// Updates the current multiplier by checking what the current multiplier has been currently set to /// and updates based on the specified conditions in CheckAndUpdateComboMultiplier /// </summary> public void updateMultiplier() { int currentmultiplier = 1; string currentMultiplierText = multiplierText.GetComponent <TMPro.TextMeshProUGUI>().text.ToString(); try { if (currentMultiplierText == "") { // set multiplier to 1 if multiplier is blank currentmultiplier = 1; } else { // otherwise, get current multiplier currentmultiplier = int.Parse(currentMultiplierText); } } catch (Exception e) { Debug.LogError("Tried to parse: " + currentMultiplierText); Debug.LogError(e.StackTrace); } multiplier = CheckAndUpdateComboMultiplier(currentmultiplier); Debug.Log("Multiplier: " + multiplier.ToString()); Debug.Log("MultiplierTextObject: " + multiplierText.ToString()); Debug.Log("MultiplierTextUpdated: " + multiplierText.GetComponent <TMPro.TextMeshProUGUI>().text.ToString()); multiplierText.GetComponent <TMPro.TextMeshProUGUI>().text = multiplier.ToString(); }
public void Equip(GameObject newitem) { Debug.Log("equipt" + newitem.ToString()); switch (newitem.GetComponent <PickUp>().type) { case 0: weaponequipped.Add(newitem.GetComponent <PickUp>().itemnumber); GetComponent <ViperControls>().guncooldown -= 0.2f; break; case 1: enginequipped.Add(newitem.GetComponent <PickUp>().itemnumber); GetComponent <ViperControls>().flySpeed += 20; break; case 2: hullequipped.Add(newitem.GetComponent <PickUp>().itemnumber); totalhp += 2; currenthp += 2; break; default: consumablequipped.Add(newitem.GetComponent <PickUp>().itemnumber); break; } }
public static void Perform(GameObject go, Animation type) { Debug.Log(go.ToString() + type.ToString()); switch (type) { case Animation.NoAnimation: break; case Animation.SolidDisappear: Destroy(go); break; case Animation.SolidMelt: SolidMelt(go, 0.8f); break; case Animation.LiquidReduce: LiquidReduce(go, 0.5f); break; case Animation.LiquidChangeColor: LiquidChangeColor(go, new Color(99f / 255, 110f / 255, 3f / 255, 141f / 255)); break; default: Debug.Log("Unrealized or Unknown Animation Type"); break; } }
private Material[] GetMaterials(GameObject monsterPrefab) { var strings = monsterPrefab.ToString().Split('_'); string name = strings[1]; // + " " + strings[2]; MonsterMat[] mats; // Material[] mats = Resources.LoadAll("SFBayStudios/SFB " + name + "/Exported Textures & Materials", // typeof(Material)).Cast<Material>().ToArray(); switch (name) { case "Mushroom": mats = m_mushroomMonsterMaterials; break; case "Plant": mats = m_plantMonsterMaterials; break; case "Rock": mats = m_rockMonsterMaterials; break; case "Worm": mats = m_wormMonsterMaterials; break; default: mats = null; Debug.LogError("Wrong monster prefab in GetMaterials in ProceduralMonsterSpawner"); break; } return(mats[Random.Range(0, mats.Length)].m_materials); }
// Start is called before the first frame update void Start() { //get a reference to the currency script attached to the manager GameObject manager = GameObject.Find("Manager"); Debug.Log("is manager null? " + manager.ToString()); currency = manager.GetComponent <Currency>(); Debug.Log("is currency script null? " + currency.ToString()); health = manager.GetComponent <Lives>(); //first time playing through if (!PlayerPrefs.HasKey("started")) { gameStartCanvas.SetActive(true); Time.timeScale = 0f; } else { gameStartCanvas.SetActive(false); } gameOverCanvas.SetActive(false); //set starting lives and currency health.lives = startingLives; currency.money = startingCurrency; }
public void OnPointerClick(PointerEventData data) { // GvrControllerInput.AppButton if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Movement Mode ON") // not able to move // remove old Sphere Collider { MeshRenderer[] objects = molecule.GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer i in objects) { GameObject atom = i.gameObject; Destroy(atom.GetComponent <SphereCollider>()); } // add Sphere Collider SphereCollider collider_molecule = molecule.AddComponent <SphereCollider>() as SphereCollider; collider_molecule.radius = 10; ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Movement Mode OFF"; } else if (ON_OFF_Button.GetComponentsInChildren <Text>()[0].text == "Movement Mode OFF") { // remove old Sphere Collider Destroy(molecule.GetComponent <SphereCollider>()); // add Sphere Collider MeshRenderer[] objects = molecule.GetComponentsInChildren <MeshRenderer>(); foreach (MeshRenderer i in objects) { GameObject atom = i.gameObject; if (atom.ToString().Contains(keyword)) { SphereCollider collider_atom = atom.AddComponent <SphereCollider>() as SphereCollider; } } ON_OFF_Button.GetComponentsInChildren <Text>()[0].text = "Movement Mode ON"; } }
/// <summary> /// Returns short information about the timer /// </summary> /// <returns>Short info about the timer</returns> public override string ToString() { return(new StringBuilder(base.ToString(), 128) .Append(" actionSource: (").Append(m_actionSource.ToString()) .Append(')') .ToString()); }
void CopyMonitoringInConsole(ErrorCode in_errorCode, ErrorLevel in_errorLevel, uint in_playingID, IntPtr in_gameObjID, string in_msg) { // Only log when logging from the engine is enabled. The callback remains active when the flag is disabled to ensure // it can be toggled on and off in a lively manner in Unity. if (engineLogging) { string msg = "Wwise: " + in_msg; if (in_gameObjID != (IntPtr)AkSoundEngine.AK_INVALID_GAME_OBJECT) { GameObject obj = EditorUtility.InstanceIDToObject((int)in_gameObjID) as GameObject; string name = obj != null?obj.ToString() : in_gameObjID.ToString(); msg += "(Object: " + name + ")"; } if (in_errorLevel == ErrorLevel.ErrorLevel_Error) { Debug.LogError(msg); } else { Debug.Log(msg); } } }
void Check(GameObject obj) { //check gameObject's number if(obj == objectList[count] && !bIsSolved) { Debug.Log ("Match! Obj: " + obj.ToString() + " Count: " + count + " ObjList: " + objectList[count].ToString()); Debug.Log ("Count List: " + objectList.Count); if(count == objectList.Count - 1) { Open (); bIsSolved = true; this.gameObject.renderer.material.color = Color.green; } count++; } else { count = 0; foreach(GameObject item in objectList) { objectList[count].SendMessage("Reset"); count++; } count = 0; this.renderer.material.color = Color.red; Debug.Log ("Reset! Count: " + count); } }
private void IsThisCurrentActiveObject(GameObject gameObject) { if (currentActiveCharacter != gameObject) { Debug.LogError(gameObject.ToString() + "is not a object which have turn now."); } }
public static float PlayGameObjectAnimation(GameObject go, string animName, float speed, float startTime) { if (go == null) { return(-1); } Animation animation = go.GetComponent <Animation>(); AnimationState animState = animation[animName]; if (animState != null) { if (startTime < 0) { startTime = animState.time; } animState.speed = speed; animState.time = startTime; animation.CrossFade(animName); return(animState.clip.length); } else { DebugEx.LogError("No animation named " + animName + " on game object " + go.ToString()); return(-1); } }
/// <summary> /// Funzione che spawna tutti gli oggetti da mettere in pool /// e controlla se implementano l'interaccia IPoolObject /// </summary> public void Init() { instance = this; poolDictionary = new Dictionary <ObjectTypes, List <IPoolObject> >(); poolParent = new GameObject("Pool").transform; poolParent.parent = transform; foreach (PoolObjects obj in poolObjects) { List <IPoolObject> objectsToAdd = new List <IPoolObject>(); Transform spawnParent = new GameObject(obj.objectType.ToString()).transform; spawnParent.parent = poolParent; for (int i = 0; i < obj.ammount; i++) { GameObject instantiateObject = Instantiate(obj.prefab, spawnParent); IPoolObject instantiateObjectInterface = instantiateObject.GetComponent <IPoolObject>(); if (instantiateObjectInterface != null) { instantiateObjectInterface.OnObjectDestroy += OnObjectDestroy; instantiateObjectInterface.OnObjectSpawn += OnObjectSpawn; instantiateObjectInterface.Setup(); OnObjectDestroy(instantiateObjectInterface); objectsToAdd.Add(instantiateObjectInterface); } else { Debug.Log("il prefab: " + instantiateObject.ToString() + " type:" + obj.objectType.ToString() + " non implementa l'interfaccia IPoolObject"); break; } } poolDictionary.Add(obj.objectType, objectsToAdd); } LevelManager.OnPlayerDeath += ResetPool; }
/// <summary> /// Finds all the UI game objects and assigns them to a variable /// </summary> void FindAllGameObjects() { //We need to make refernces to various buttons/text game objects, but using GameObject.Find is inefficient if we do it every update. //Therefore, we assign variables to them and only use GameObject.Find once for each object in startup. navigationPanel = AuxFunctions.FindObject(gameObject, "NavigationPanel"); selectionPanel = AuxFunctions.FindObject(gameObject, "SelectionPanel"); //The Mode Selection Tab GUI Objects defaultSimulator = AuxFunctions.FindObject(gameObject, "DefaultSimulator"); mixAndMatchMode = AuxFunctions.FindObject(gameObject, "MixAndMatchMode"); simLoadField = AuxFunctions.FindObject(gameObject, "SimLoadField"); simLoadRobot = AuxFunctions.FindObject(gameObject, "SimLoadRobot"); simLoadReplay = AuxFunctions.FindObject(gameObject, "SimLoadReplay"); splashScreen = AuxFunctions.FindObject(gameObject, "LoadSplash"); errorScreen = AuxFunctions.FindObject(gameObject, "ErrorScreen"); graphics = AuxFunctions.FindObject(gameObject, "Graphics"); input = AuxFunctions.FindObject(gameObject, "Input"); settingsMode = AuxFunctions.FindObject(gameObject, "SettingsMode"); errorText = AuxFunctions.FindObject(errorScreen, "ErrorText").GetComponent <Text>(); simFieldSelectText = AuxFunctions.FindObject(defaultSimulator, "SimFieldSelectText"); simRobotSelectText = AuxFunctions.FindObject(defaultSimulator, "SimRobotSelectText"); AuxFunctions.FindObject(gameObject, "QualitySettingsText").GetComponent <Text>().text = QualitySettings.names[QualitySettings.GetQualityLevel()]; mixAndMatchModeScript = AuxFunctions.FindObject(gameObject, "MixAndMatchModeScript"); Debug.Log(mixAndMatchModeScript.ToString()); }
// Use this for initialization void Start() { Camera cam = GameObject.Find("MainCamera").GetComponent <Camera>(); m_H = cam.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height)).y * 2; m_W = cam.ScreenToWorldPoint(new Vector2(Screen.width, Screen.height)).x * 2; m_W -= (m_W % GameInfo.cellSide); if (Ball != null) { m_ball = Ball; } else { m_ball = GameObject.Find("Ball").GetComponent <Ball>(); } Transform[] levels = GameObject.Find("Levels").GetComponentsInChildren <Transform>(); foreach (Transform item in levels) { GameObject obj = item.gameObject; if (obj.ToString().IndexOf("Level_") >= 0) { m_levels.Enqueue(obj); } } NextLevel(); }
/** Returns sorted list of touched objects. First is nearest. */ public GameObject MouseOverObject(LayerMask mask, out List <GameObject> collidedObjs) { GameObject topObj = null; int topObjSortingLevel = -2; collidedObjs = new List <GameObject>(); // get collided objs with 2d colliders Vector2 from2D = MouseToSceneZeroZPosition(); RaycastHit2D[] hits2D = Physics2D.RaycastAll(from2D, Vector2.up, 0, mask); int cnt2D = hits2D.Length; for (int i = 0; i < cnt2D; ++i) { UnityEngine.GameObject obj = hits2D[i].collider.gameObject; collidedObjs.Add(obj); Debug.Assert(Mathf.Abs(obj.transform.position.z) < 0.1f, "Touched object " + obj + " top " + obj.GameObjectTop() + " collision is not on zero Z " + obj.transform.position.z, true); } // get collided objs with 3d colliders _mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit[] hits3D = Physics.RaycastAll(_mouseRay, RAY_DISTANCE, mask); int cnt3D = hits3D.Length; for (int i = 0; i < cnt3D; ++i) { collidedObjs.Add(hits3D[i].collider.gameObject); } #if DEBUG string mouseRayText = "mouseRay px " + _mouseRay.origin.x + " py " + _mouseRay.origin.y + " pz " + _mouseRay.origin.z + " dx " + _mouseRay.direction.x + " dy " + _mouseRay.direction.y + " dz " + _mouseRay.direction.z; Debug.Log(mouseRayText); string debug = "ManagerCtrl.MouseOverObject choosing between " + collidedObjs.Count + ": "; // mouseRay " + _mouseRay + " #endif foreach (GameObject collidedObj in collidedObjs) { int hitSortingLevel = Picus.Utils.SortingLayer.RecomputedSortingLevel(collidedObj); if (hitSortingLevel > topObjSortingLevel) { topObjSortingLevel = hitSortingLevel; topObj = collidedObj; } #if DEBUG string topInfo = collidedObj.ToString(); // (collidedObj.GameObjectTopInfo<GameObjectTopInfo>() == null ? "NO_GO_TOPINFO " + collidedObj : collidedObj.GameObjectTopInfo<GameObjectTopInfo>().ShortName()); debug += " '" + topInfo + "'(" + hitSortingLevel + ") "; #endif } #if DEBUG if (topObj != null) { debug = debug + " => '" + topObj.ToString(); // (topObj.GameObjectTop() == null ? "NONAME" : topObj.GameObjectTopInfo<Utils.GameObjectTopInfo>() == null ? "NO_TOPINFO`" : topObj.GameObjectTopInfo<Utils.GameObjectTopInfo>().Name()) + "'"; } Debug.Log(debug); #endif return(topObj); }
// Start is called before the first frame update void Start() { ball = GameObject.FindWithTag("Ball"); if (ball == null) { Debug.Log("Problem ze znalezieniem piłki " + ball.ToString()); } }
// Use this for initialization void Start() { gl = (GameLogic)FindObjectOfType(typeof(GameLogic)); ft = (FractalTexture)FindObjectOfType(typeof(FractalTexture)); pl = (Player)FindObjectOfType(typeof(Player)); whiteNoise = GameObject.Find("WhiteNoise"); Debug.Log("White Noise: " + whiteNoise.ToString()); }
void Start() { currentScene = Object.Instantiate (scenePrefabs[0]); metricController = GetComponent<MetricController>(); totalTimeSpentDrinkingCoffee = 0.0f; Debug.Log (currentScene.ToString ()); fader = c.GetComponent<Fade> (); IsGameOver = false; fader.FadeIn (); }
public void setDrone(int role, GameObject obj) { switch(role) { case 0: droneLeft = obj; break; case 1: droneRight = obj; break; case 2: droneBack = obj; break; default: Debug.Log("Error : unknown role for drone "+obj.ToString()); break; } }
static GameObject GetCache(GameObject G) { if (G == null) throw new System.Exception("Constraint Spawner null object requested"); if (Cache == null) Cache = new Dictionary<GameObject, GameObject>(); if (!Cache.ContainsKey(G)) Cache[G] = (GameObject)Instantiate(G, new Vector3(0, -100, 0), new Quaternion()); if (!Cache.ContainsKey(G)) throw new System.Exception(G.ToString() + " Constraint spawner could not spawn blueprint"); return Cache[G]; }
void LoadMagePrefs() { selectedCharacter = Mage; Debug.Log(selectedCharacter.ToString()); if (GameObject.Find("Picture")) { ImageOff.enabled = true; GameObject SelectImage = GameObject.Find("CharacterPicture"); Image MagePicture = SelectImage.GetComponent<Image>(); MagePicture.sprite = MagePic; } if (GameObject.Find("Atributos")) { //Procura os gameobjects GameObject WriteHP = GameObject.Find("HPText"); GameObject WriteMP = GameObject.Find("MPText"); GameObject WriteSTR = GameObject.Find("STRText"); GameObject WriteVIT = GameObject.Find("VITText"); GameObject WriteDEX = GameObject.Find("DEXText"); GameObject WriteINT = GameObject.Find("INTText"); //Escreve nas labels. Text textHP = WriteHP.GetComponent<Text>(); textHP.text = "100".ToString(); Text textMP = WriteMP.GetComponent<Text>(); textMP.text = "150".ToString(); Text textSTR = WriteSTR.GetComponent<Text>(); textSTR.text = "7 *1.8".ToString(); Text textVIT = WriteVIT.GetComponent<Text>(); textVIT.text = "5 *1.7".ToString(); Text textDEX = WriteDEX.GetComponent<Text>(); textDEX.text = "5 * 1.7".ToString(); Text textINT = WriteINT.GetComponent<Text>(); textINT.text = "12 *1.5".ToString(); } if (GameObject.Find("Skills")) { GameObject WriteSkill1 = GameObject.Find("Skill1Text"); GameObject WriteSkill2 = GameObject.Find("Skill2Text"); GameObject WriteSkill3 = GameObject.Find("Skill3Text"); Text textSkill1 = WriteSkill1.GetComponent<Text>(); textSkill1.text = "Fireball".ToString(); Text textSkill2 = WriteSkill2.GetComponent<Text>(); textSkill2.text = "Throw Stone".ToString(); Text textSkill3 = WriteSkill3.GetComponent<Text>(); textSkill3.text = "Water Blast".ToString(); } }
void Generate() { if(numLeft > 0) { current = GameObject.Instantiate(blockProto, Vector3.zero, Quaternion.identity) as GameObject; Debug.Log (current.ToString()); Debug.Log (current.GetType ().ToString()); current.transform.SetParent (gameObject.transform); current.transform.localPosition = new Vector3(0.6f, 0, 0); current.transform.localScale = new Vector3(1, 1, 1); current.GetComponent<ProgBlock>().onPickup += OnPickup; } }
public Pool(GameObject obj, GameObject parent, int size) { index = 0; GameObject container = new GameObject("Pool"+obj.ToString()); container.transform.SetParent(parent.transform); for (int i = 0; i < size; i++) { GameObject instance = GameObject.Instantiate(obj); instance.transform.parent = container.transform; instance.SetActive(false); objects.Add(instance); } }
public override int Assign(GameObject entity) { if (entityMap [0] == null) { FormationLeader = entity; entityMap [0] = entity; return 0; } else if (entityMap [1] == null) { entityMap [1] = entity; return 1; } else { throw (new UnityException ("Tried to Assign entity " + entity.ToString () + " to a full formation.")); } }
public void onSelection(GameObject selected) { Debug.Log (selected.ToString()); if (buttons != null) { foreach(Button b in buttons){ b.image.sprite = offSprite; //Debug.Log(b.ToString); } Image i = selected.GetComponent<Image>(); i.sprite = onSprite; } }
/// <summary> /// Checks to see if an entity is tagged with a specified tag /// </summary> /// <param name="Entity"></param> /// <param name="Tag"></param> /// <returns></returns> public static bool EntityIs(GameObject Entity,Tag Tag) { EntityTag _Tag = Entity.GetComponent<EntityTag>(); if (!_Tag) { Debug.Log("Game Object does not contain an EntityTag: " + Entity.ToString()); return false; } else { return _Tag.Is(Tag); } }
Color defaultGUI = Color.white; // set to white to avoid errors (Color is non-nullable) #endregion Fields #region Methods // add an item to the inventory public void AddItem(GroundItem i) { // only add items if there's room in the inventory if (!IsFull()) { // create a new game object and give it a held item script GameObject toAdd = new GameObject(i.name); toAdd.AddComponent<HeldItem>(); toAdd.GetComponent<HeldItem>().Initialize(i.GetComponent<SpriteRenderer>().sprite, i.cooldown); toAdd.GetComponent<HeldItem>().projectile = i.projectile; // add the new item to the inventory inv[currentItems] = toAdd; currentItems++; Destroy(i.gameObject); Debug.Log("Item \"" + toAdd.ToString() + "\" added to inventory"); } }
//void cameraTrack_Lerp(GameObject player) //{ // //Vector3 playerPos = // //mainCamera.transform.position = new Vector3(mainCamera.transform.position.x, player.transform.position.y, mainCamera.transform.position.z); // Debug.Log("cameraTrack_Lerp called"); // Debug.Log("player available while rotation: " + player.ToString()); // float wantedHeight = player.transform.position.y; // Vector3 targetPos = new Vector3(mainCamera.transform.position.x, wantedHeight, mainCamera.transform.position.z); // mainCamera.transform.position = Vector3.Lerp(mainCamera.transform.position, targetPos, heightDamping * Time.deltaTime); //} private void cameraMove_Lerp(GameObject player) { if(_isAdjustingCamera == true) { //_isAdjustingCamera = true; //mainCamera.transform.position = new Vector3(mainCamera.transform.position.x, player.transform.position.y, mainCamera.transform.position.z); Debug.Log("cameraMove_Lerp called"); Debug.Log("player available while rotation: " + player.ToString()); float wantedHeight = player.transform.position.y; float currentHeight = mainCamera.transform.position.y; //Vector3 targetPos = new Vector3(mainCamera.transform.position.x, wantedHeight, mainCamera.transform.position.z); Vector3 amount = new Vector3(0, wantedHeight - currentHeight, 0); Debug.Log("amount" + amount); //mainCamera.transform.position = Vector3.MoveTowards(mainCamera.transform.position, targetPos, heightDamping * Time.deltaTime); //iTween.MoveAdd(mainCamera, amount, timeAdjustingCamera); iTween.MoveAdd(mainCamera, iTween.Hash(iT.MoveAdd.time, timeAdjustingCamera, iT.MoveAdd.amount, amount, iT.MoveAdd.oncomplete, "onAdjustCameraComplete", iT.MoveAdd.oncompletetarget, gameObject)); } }
public override void Act(GameObject player, GameObject npc) { Debug.Log("FollowPath: ACT"); Debug.Log("FollowPath: player - "+player.ToString()+". npc - "+npc.ToString()); // Follow the path of waypoints // Find the direction of the current way point //Vector3 vel = npc.rigidbody.velocity; Vector3 vel = npc.GetComponent<Rigidbody>().velocity; Vector3 moveDir = waypoints[currentWayPoint].position - npc.transform.position; if (moveDir.magnitude < 1) { currentWayPoint++; Debug.Log("FollowPath: Incrementa WayPoint"); if (currentWayPoint >= waypoints.Length) { currentWayPoint = 0; } } else { Debug.Log("FollowPath: SEGUINDO WayPoints"); vel = moveDir.normalized * NPCControl.GetVelocityFactor(); Debug.DrawRay(npc.transform.position,moveDir); // Rotate towards the waypoint npc.transform.rotation = Quaternion.Slerp(npc.transform.rotation, Quaternion.LookRotation(moveDir), 2 * Time.deltaTime); //npc.transform.rotation.ToAngleAxis(180f,Vector3.up); //npc.transform.RotateAround(npc.transform.position,Vector3.up, 180.0f); //npc.transform.rotation = Quaternion.LookRotation(moveDir); npc.transform.eulerAngles = new Vector3(0, npc.transform.eulerAngles.y, 0); } // Apply the Velocity //npc.rigidbody.velocity = vel; npc.GetComponent<Rigidbody> ().velocity = vel; }
public override void Start() { satanicParticle = (GameObject)Resources.Load("SatanicParticle"); Debug.Log("player found " + player); if (ai == aiTypes.followMop && followWho == null) { followWho = GameObject.FindGameObjectWithTag("Enemy"); Debug.Log("following " + followWho.ToString()); } player = GameObject.FindGameObjectWithTag("Player"); base.Start(); recipeManager = GameObject.FindGameObjectWithTag("RecipePanel").GetComponent<Recipe>(); animator.Play("book_armature|walk"); }
void OnFacilityCreate(GameObject _Facility) { // If trigger radius >= (Vec1 - Vec2).magnitude if (m_fTriggerRadius.Get() >= ((_Facility.transform.position - transform.position).magnitude)) { // If facility is NOT a member of the facility list if (!ListSearch(_Facility)) { NearbyFacilities.Add(_Facility); //CGameShips.Ship.GetComponent<CFacilityGravity>().AddGravitySource(gameObject); } // Default else { Debug.LogError("CGravityTriggerResponse.cs attempted" + "to call OnFacilityCreate(" + _Facility.ToString() + ")." + "Event parameter object is already a member of the facility list."); } } }
// Update is called once per frame void Update () { if (CanWin) { try { Tank = GameObject.FindGameObjectWithTag ("Tank"); Debug.Log (Tank.ToString ()); UpdateTxt = System.Math.Round ((Time.time), 2).ToString (); DoMagical.text = UpdateTxt; } catch { float WinTime = (float)System.Math.Round ((Time.time), 2); if (WinTime < SaveScore.GetCurrentHigh() || SaveScore.GetCurrentHigh() == 0.0f){ string Winner = "You won in " + WinTime.ToString () + " seconds try to beat your New high score!"; DoMagical.text = Winner; SaveScore.SaveScores(WinTime); SaveScore.LoadScores(); } else { string Winner = "You won in " + WinTime.ToString () + " seconds try to beat your high score!"; DoMagical.text = Winner; } CanWin = false; } } }
private void LoadMenu(GameObject food, Button m_button, Text m_text, GameObject m_image, GameObject i1, GameObject i2, GameObject i3, GameObject i4) { m_button.onClick.RemoveAllListeners(); m_button.onClick.AddListener(() => ShowFood(food)); m_text.text = food.ToString().Replace(" (UnityEngine.GameObject)", ""); if (food.GetComponent<Food>().level > 0) m_text.text += "\nLevel " + food.GetComponent<Food>().level; else m_text.text += "\n<Unlock>"; if (GetComponent<FoodVariables>().GetAllSelectedRecipes().Contains(food)) m_button.GetComponent<Image>().color = selected; else m_button.GetComponent<Image>().color = Color.white; //Food if (food.GetComponent<Food>().menuSprite != null) m_image.GetComponent<Image>().sprite = food.GetComponent<Food>().menuSprite; else m_image.GetComponent<Image>().sprite = defaultFoodSprite; //Ingredients try { if (food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().image != null) i1.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().image; else i1.GetComponent<Image>().sprite = defaultIngredientSprite; if (food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().quatity > 0) i1.GetComponent<Image>().color = Color.white; else i1.GetComponent<Image>().color = faded; i1.SetActive(true); } catch { i1.SetActive(false); } try { if (food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().image != null) i2.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().image; else i2.GetComponent<Image>().sprite = defaultIngredientSprite; if(food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().quatity > 0) i2.GetComponent<Image>().color = Color.white; else i2.GetComponent<Image>().color = faded; i2.SetActive(true); } catch { i2.SetActive(false); } try { if (food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().image != null) i3.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().image; else i3.GetComponent<Image>().sprite = defaultIngredientSprite; if (food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().quatity > 0) i3.GetComponent<Image>().color = Color.white; else i3.GetComponent<Image>().color = faded; i3.SetActive(true); } catch { i3.SetActive(false); } try { if (food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().image != null) i4.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().image; else i4.GetComponent<Image>().sprite = defaultIngredientSprite; if (food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().quatity > 0) i4.GetComponent<Image>().color = Color.white; else i4.GetComponent<Image>().color = faded; i4.SetActive(true); } catch { i4.SetActive(false); } }
public void LeftClickGrid(GameObject button) { if (!isLocalPlayer) return; if (isSelected) { if(button.name == "Grid Trash") { ThrowAwayItem(selectedName); } else if((!(items[selectedName].Equals(batSprite) || items[selectedName].Equals(pistolSprite))) && button.name == "Grid Weapon") { } else if(!items[selectedName].Equals(ammoSprite) && button.name == "Grid Ammo") { } else if(selectedName == "Grid Weapon" && !(items[button.name].Equals(pistolSprite) || items[button.name].Equals(batSprite))) { } else if(!items[button.name].Equals(ammoSprite) && selectedName == "Grid Ammo") { } else { Sprite tempImag = items[button.name]; items[button.name] = items[selectedName]; items[selectedName] = tempImag; } isSelected = false; GameObject.Find(selectedName).GetComponent<Image>().color = gridColor; selectedName = ""; } else { // Cannot select trash grid if(button.name == "Grid Trash") return; // Cannot select ammo grid if(button.name == "Grid Ammo") return; // Cannot select empty grid if(items[button.name].Equals(gridImage)) return; isSelected = true; selectedName = button.name; button.GetComponent<Image>().color = selectedColor; } if (items ["Grid Weapon"].Equals (pistolSprite)) this.GetComponent<Player_BasicAttacks>().EquipPistol(); if(items["Grid Weapon"].Equals(batSprite)) this.GetComponent<Player_BasicAttacks>().EquipBat(); if(items["Grid Weapon"].Equals(gridImage)) this.GetComponent<Player_BasicAttacks>().Unequip(); Debug.Log (button.ToString()); }
void Initialize() { Debug.Log("GameController initializing"); DynamicObstacles = new List<DynamicObstacle>(); for (int i = 0; i < InitialAmountOfDynamicObstacles; i++) { Invoke("SpawnDynamicObstacle", 3f + (float)i * 0.1f); } if (SpawnPeriodically) { InvokeRepeating("SpawnDynamicObstacle", SpawnInterval, SpawnInterval); } if (SwapTypesPeriodically) { InvokeRepeating("SwapDynamicObstacleTypes", SwapTypesInterval, SwapTypesInterval); } if (AudioController == null) { AudioController = this.GetComponent<AudioController>(); } #region Get Player Reference if (Player != null) { _player = Player.GetComponent<PlayerController>(); if (_player == null) { Debug.LogError("Could not find PlayerController component on Player: " + Player.ToString()); } } else { Player = GameObject.FindGameObjectWithTag("Player"); if (Player != null) { _player = Player.GetComponent<PlayerController>(); if (_player == null) { Debug.LogError("Could not find PlayerController component on Player: " + Player.ToString()); } } else { Debug.LogError("Player oject has not been set on GameController and could not be automatically found"); } } #endregion }
public void AssignCamera( GameObject target ) { Debug.Log( "Targeting " + target.ToString() + " with main camera" ); FollowCamera camera = GameObject.FindGameObjectWithTag( Tags.MainCamera ).GetComponent<FollowCamera>(); camera.target = target; }
public void TouchCheck(){ #if UNITY_IPHONE if( Input.touchCount > 0 ){ Touch touch = Input.getTouch( 0 ); if( touch.phase == TouchPhase.Began ){ ControlPosition = touch.position; cameraray = Camera.main.ScreenPositionToRay( ControlPosition ); if( Physics.Raycast( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){ TouchObject = cameraraycasthit.collider.gameObject; flowflg = true; } } else if( touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary ){ ControlPosition = touch.position; } else{ flowflg = false; } } #endif #if UNITY_EDITOR /* //ボタンを押し続けている間 if( Input.GetMouseButton ( 0 ) ){ ControlPosition = Input.mousePosition; flowflg = true; } */ //ボタンを押した瞬間 if( Input.GetMouseButtonDown( 0 ) ){ //cameraray //Debug.Log ( "InputLeft" ); ControlPosition = Input.mousePosition; cameraray = Camera.main.ScreenPointToRay( ControlPosition ); //もしクリックしたときに何かオブジェクトにぶつかったとき if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity ) ){ //オブジェクトの情報を返す RayHiter = cameraraycasthit.collider.gameObject; flowflg = true; if( RayHiter.ToString().Contains( "Button" ) ){ RayHiter.GetComponent<Button>().OnButton( prevData, nowData ); } } //flowflg = true; /* ControlPosition.x = ControlPosition.x; ControlPosition.z = ControlPosition.y; ControlPosition.y = -50.0f; */ //ControlPosition.z = Camera.main.transform.position.y; //Debug.Log( ControlPosition ); //Camera.main.ScreenToWorldPoint(clickPosition) //cameraray = Camera.main.ScreenPointToRay( ControlPosition ); //cursor.z = Camera.main.transform.position.y } if( Input.GetMouseButtonUp( 0 ) ){ ButtonUpSendflg = true; flowflg = false; } #endif /* cameraray = Camera.main.ScreenPointToRay( ControlPosition ); if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){ if( flowflg ){ //Debug.Log( cameraraycasthit.collider.gameObject.name ); if( cameraraycasthit.collider.gameObject.ToString().Contains( "medal" ) ){ cameraraycasthit.collider.gameObject.GetComponent<medal>().MakeObject(); } TouchObject = cameraraycasthit.collider.gameObject; if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){ if( cameraraycasthit.collider.gameObject.ToString().Contains( "BumpObject" ) ){ Debug.Log( "test" ); cameraraycasthit.collider.gameObject.GetComponent<BumpObject>().UpDataPosition( ); } } //Instantiate( testbox, ControlPosition, Quaternion.identity ); //flowflg = true; } } */ /* if ( !cameraraycasthit.collider.gameObject == null ) { if ( cameraraycasthit.collider.ToString ().Contains ("medal") ) { //cameraraycasthit.collider.GetComponent<>() Debug.Log (cameraraycasthit.collider.ToString()); } } */ /* if( flowflg ){ //当たったオブジェクトのチェック if( RayHiter.ToString().Contains( "Button" ) ){ //ポジション切り替え部分 Vector3 test; Debug.Log("test"); //ポジション切り替え部分 test = Camera.main.ScreenToWorldPoint( new Vector3( ControlPosition.x, ControlPosition.y, 50.0f ) ); //RayHiter.GetComponent<medal>().MakeObject( test ); if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){ RayHiter = cameraraycasthit.collider.gameObject; } //cameraraycasthit.collider.gameObject.GetComponent<medal>().MakeObject( test ); } */ /* if( RayHiter.ToString().Contains( "BumpObject" ) ){ Vector3 test; test = Camera.main.ScreenToWorldPoint( new Vector3( ControlPosition.x, ControlPosition.y, 50.0f ) ); RayHiter.GetComponent<BumpObject>().UpDataPosition( test ); } */ /* } if( ButtonUpSendflg ){ //Vector3 test; //test = Camera.main.ScreenToWorldPoint( new Vector3( ControlPosition.x, ControlPosition.y, 50.0f ) ); //RayHiter.GetComponent<medal>().MakeObject( test ); */ /* if( Physics.Raycast ( cameraray.origin, cameraray.direction, out cameraraycasthit, Mathf.Infinity, raylayermask ) ){ RayHiter = cameraraycasthit.collider.gameObject; } */ // //RayHiter.GetComponent<medal>().MoveOrigin( test ); /* ButtonUpSendflg = false; } */ }
public void DestroyFacility(GameObject _Facility) { if (EventOnFaciltiyDestroy != null) { EventOnFaciltiyDestroy(_Facility); } Debug.Log("DestroyFacility(" + _Facility.ToString() + "); was called, but the function is empty so nothing happened. Durp."); }
void LoadKnightPrefs() { selectedCharacter = Knight; Debug.Log(selectedCharacter.ToString()); if (GameObject.Find("Picture")) { ImageOff.enabled = true; GameObject SelectImage = GameObject.Find("CharacterPicture"); Image KnightPicture = SelectImage.GetComponent<Image>(); KnightPicture.sprite = KnightPic; } if (GameObject.Find("Atributos")) { //Procura os gameobjects GameObject WriteHP = GameObject.Find("HPText"); GameObject WriteMP = GameObject.Find("MPText"); GameObject WriteSTR = GameObject.Find("STRText"); GameObject WriteVIT = GameObject.Find("VITText"); GameObject WriteDEX = GameObject.Find("DEXText"); GameObject WriteINT = GameObject.Find("INTText"); //Escreve nas labels. Text textHP = WriteHP.GetComponent<Text>(); textHP.text = "200".ToString(); Text textMP = WriteMP.GetComponent<Text>(); textMP.text = "50".ToString(); Text textSTR = WriteSTR.GetComponent<Text>(); textSTR.text = "12 *1.3".ToString(); Text textVIT = WriteVIT.GetComponent<Text>(); textVIT.text = "8 *1.4".ToString(); Text textDEX = WriteDEX.GetComponent<Text>(); textDEX.text = "2 *2.2".ToString(); Text textINT = WriteINT.GetComponent<Text>(); textINT.text = "2 *2.2".ToString(); } if (GameObject.Find("Skills")) { GameObject WriteSkill1 = GameObject.Find("Skill1Text"); GameObject WriteSkill2 = GameObject.Find("Skill2Text"); GameObject WriteSkill3 = GameObject.Find("Skill3Text"); Text textSkill1 = WriteSkill1.GetComponent<Text>(); textSkill1.text = "Firesword".ToString(); Text textSkill2 = WriteSkill2.GetComponent<Text>(); textSkill2.text = "Flamesword".ToString(); Text textSkill3 = WriteSkill3.GetComponent<Text>(); textSkill3.text = "None".ToString(); } }
private int getIndex(GameObject menu) { string getIndex = menu.ToString().Substring(9, 1); int index = int.Parse (getIndex); return index; }
public void ShowIngredient(GameObject ingredient, int flag) { marketScroll.SetActive(false); f_button_panel1.SetActive(false); f_button_panel2.SetActive(true); f_food_image.SetActive(false); f_ingredient_image.SetActive(true); //Back Button f_close.onClick.RemoveAllListeners(); f_close.onClick.AddListener(() => LoadMarket(menuScrollIndex)); f_close.onClick.AddListener(() => CloseFoodSelection()); //Description f_desc.text = ingredient.ToString().Replace(" (UnityEngine.GameObject)", ""); //Food Image if (ingredient.GetComponent<Ingredient>().image != null) f_ingredient_image.GetComponent<Image>().sprite = ingredient.GetComponent<Ingredient>().image; else f_ingredient_image.GetComponent<Image>().sprite = defaultFoodSprite; foodSelection.SetActive(true); //Ingredient Images f_ingredient1.SetActive(false); f_ingredient2.SetActive(false); f_ingredient3.SetActive(false); f_ingredient4.SetActive(false); //Yes and No Buttons f_yes_button.interactable = true; f_yes_button.onClick.RemoveAllListeners(); f_yes_button.onClick.AddListener(() => ingredient.GetComponent<Ingredient>().quatity++); f_yes_button.onClick.AddListener(() => LoadMarket(menuScrollIndex)); f_yes_button.onClick.AddListener(() => CloseFoodSelection()); f_no_button.interactable = true; f_no_button.onClick.RemoveAllListeners(); f_no_button.onClick.AddListener(() => LoadMarket(menuScrollIndex)); f_no_button.onClick.AddListener(() => CloseFoodSelection()); if (flag == 0) { if (GetComponent<GlobalVariables>().money >= ingredient.GetComponent<Ingredient>().GetSalePrice()) f_yes_button.onClick.AddListener(() => GetComponent<GlobalVariables>().AddMoney(-(ingredient.GetComponent<Ingredient>().GetSalePrice()))); else f_yes_button.interactable = false; f_desc.text += "\nSale Price : $" + ingredient.GetComponent<Ingredient>().GetSalePrice(); } else if (flag == 1) { if (GetComponent<GlobalVariables>().money >= ingredient.GetComponent<Ingredient>().marketPrice) f_yes_button.onClick.AddListener(() => GetComponent<GlobalVariables>().AddMoney(-(ingredient.GetComponent<Ingredient>().marketPrice))); else f_yes_button.interactable = false; f_desc.text += "\nMarket Price : $" + ingredient.GetComponent<Ingredient>().marketPrice; } else { if (GetComponent<GlobalVariables>().money >= ingredient.GetComponent<Ingredient>().GetRarePrice()) f_yes_button.onClick.AddListener(() => GetComponent<GlobalVariables>().AddMoney(-(ingredient.GetComponent<Ingredient>().GetRarePrice()))); else f_yes_button.interactable = false; f_desc.text += "\nRarity Price : $" + ingredient.GetComponent<Ingredient>().GetRarePrice(); } }
public void ShowFood(GameObject food) { MenuType2 = "Food"; menuScroll.SetActive(false); bool canLevel = true; f_food_image.SetActive(true); f_ingredient_image.SetActive(false); f_button_panel1.SetActive(true); f_button_panel2.SetActive(false); f_price_info.SetActive(false); //Yes and No Buttons f_yes_button.interactable = true; f_yes_button.onClick.RemoveAllListeners(); f_yes_button.onClick.AddListener(() => ConfirmLevel(food)); f_no_button.interactable = true; f_no_button.onClick.RemoveAllListeners(); f_no_button.onClick.AddListener(() => DeclineLevel()); //Back Button f_close.onClick.RemoveAllListeners(); f_close.onClick.AddListener(() => CloseFoodSelection()); if (MenuType == "Appetizers") f_close.onClick.AddListener(() => LoadAppetizers(menuScrollIndex)); else if (MenuType == "Entrees") f_close.onClick.AddListener(() => LoadEntrees(menuScrollIndex)); else if (MenuType == "Desserts") f_close.onClick.AddListener(() => LoadDesserts(menuScrollIndex)); //Buttons f_level_button.onClick.RemoveAllListeners(); if(food.GetComponent<Food>().level > 0) { f_level_text.text = "Level Up"; f_price_text.text = "Pricing"; f_price_button.interactable = true; f_price_button.onClick.RemoveAllListeners(); f_price_button.onClick.AddListener(() => ShowPricingOptions(food)); //Select Button f_select_button.onClick.RemoveAllListeners(); f_select_button.interactable = true; if(GetComponent<FoodVariables>().GetAllSelectedRecipes().Contains(food)) { //Already Selected SelectToggle(true, food); if (food.GetComponent<Food>().type == "Appetizer") { if(GetComponent<FoodVariables>().GetAppetizers().Count == 1) { f_select_button.interactable = false; } Debug.Log("Appetizers = " + GetComponent<FoodVariables>().GetAppetizers().Count); } else if (food.GetComponent<Food>().type == "Entree") { if (GetComponent<FoodVariables>().GetEntrees().Count == 1) { f_select_button.interactable = false; } Debug.Log("Entrees = " + GetComponent<FoodVariables>().GetEntrees().Count); } } else { //Can Be Selected SelectToggle(false, food); } } else { f_level_text.text = "Unlock"; f_select_button.interactable = false; f_price_button.interactable = false; } //Description f_desc.text = food.ToString().Replace(" (UnityEngine.GameObject)", ""); if (food.GetComponent<Food>().level > 0) f_desc.text += "\nLevel " + food.GetComponent<Food>().level; else f_desc.text += "\n<Unlock>"; //Food Image if (food.GetComponent<Food>().menuSprite != null) f_food_image.GetComponent<Image>().sprite = food.GetComponent<Food>().menuSprite; else f_food_image.GetComponent<Image>().sprite = defaultFoodSprite; //Ingredient Images try { if (food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().image != null) f_ingredient1.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().image; else f_ingredient1.GetComponent<Image>().sprite = defaultIngredientSprite; if (food.GetComponent<Food>().recipe[0].GetComponent<Ingredient>().quatity == 0) { canLevel = false; f_ingredient1.GetComponent<Image>().color = faded; } else { f_ingredient1.GetComponent<Image>().color = Color.white; } f_ingredient1.SetActive(true); } catch { f_ingredient1.SetActive(false); } try { if (food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().image != null) f_ingredient2.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().image; else f_ingredient2.GetComponent<Image>().sprite = defaultIngredientSprite; if (food.GetComponent<Food>().recipe[1].GetComponent<Ingredient>().quatity == 0) { canLevel = false; f_ingredient2.GetComponent<Image>().color = faded; } else { f_ingredient2.GetComponent<Image>().color = Color.white; } f_ingredient2.SetActive(true); } catch { f_ingredient2.SetActive(false); } try { if (food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().image != null) f_ingredient3.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().image; else f_ingredient3.GetComponent<Image>().sprite = defaultIngredientSprite; if (food.GetComponent<Food>().recipe[2].GetComponent<Ingredient>().quatity == 0) { canLevel = false; f_ingredient3.GetComponent<Image>().color = faded; } else { f_ingredient3.GetComponent<Image>().color = Color.white; } f_ingredient3.SetActive(true); } catch { f_ingredient3.SetActive(false); } try { if (food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().image != null) f_ingredient4.GetComponent<Image>().sprite = food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().image; else f_ingredient4.GetComponent<Image>().sprite = defaultIngredientSprite; if (food.GetComponent<Food>().recipe[3].GetComponent<Ingredient>().quatity == 0) { canLevel = false; f_ingredient4.GetComponent<Image>().color = faded; } else { f_ingredient4.GetComponent<Image>().color = Color.white; } f_ingredient4.SetActive(true); } catch { f_ingredient4.SetActive(false); } //Level Up Button Continued... if(canLevel) { f_level_button.onClick.AddListener(() => ShowLevelConfirmation()); f_level_button.interactable = true; } else { f_level_button.interactable = false; } foodSelection.SetActive(true); }
/// <summary> /// S'il existe un vertex ayant pour GameObject celui pass� en param�tre alors m_vertexSelected prend sa valeur. /// </summary> public void selectVertexFromGameObject(GameObject go) { Debug.Log("gameobject selected :" + go.ToString()); foreach (PVertex v in m_vertices) { if (v.gameObject == go) { //on remet l'ancien vertex en bleu if (m_vertexSelected != null) { m_vertexSelected.gameObject.GetComponent<Renderer>().material.SetColor("_Color",UNSELECTED_COLOR); } else if (m_vertices.Count > 0) { PVertex selected = m_vertices.Last.Value; selected.gameObject.GetComponent<Renderer>().material.SetColor("_Color",UNSELECTED_COLOR); } m_vertexSelected = v; //on met le nouveau en vert m_vertexSelected.gameObject.GetComponent<Renderer>().material.SetColor("_Color",SELECTED_COLOR); break; } } }
public Vector3 getTargetPosition(GameObject entity) { // formations have relatively small sizes (less than 10), so a linear search should be efficient enough for (int i=0; i<entityMap.Length; i++) { if (entityMap [i] == entity) return getTargetPosition (i); } throw new KeyNotFoundException ("Entity " + entity.ToString () + " not found in formation " + this.ToString ()); }