当前位置: 首页>>代码示例>>C#>>正文


C# Monster.ScaleToLevel方法代码示例

本文整理汇总了C#中Monster.ScaleToLevel方法的典型用法代码示例。如果您正苦于以下问题:C# Monster.ScaleToLevel方法的具体用法?C# Monster.ScaleToLevel怎么用?C# Monster.ScaleToLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Monster的用法示例。


在下文中一共展示了Monster.ScaleToLevel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeMonsters

	void InitializeMonsters() {
		GameObject canvas = GameObject.Find("Canvas");

		for (int i = 0; i < number_of_monsters; i++){
			int rand_id = ItemGenerator.LootIDGenerator("Monsters");
			Monster monster = CardLibrary.Instance().GetCardData(rand_id) as Monster;
			monster = new Monster(monster);
			monster.level = Random.Range(1, 3);
			monster.ScaleToLevel();
			monster.material = Factory.instance.TestBake(monster);
			GameObject monster_spawn = (GameObject)Instantiate(card_prefab, transform.GetChild(0).position, transform.GetChild(0).rotation);
			monster_spawn.GetComponent<CardScript>().Prepare(rand_id, monster.material);
			monster_spawn.AddComponent<Controller>();
			monster_spawn.GetComponent<Controller>().Clone(monster);
			monster_spawn.GetComponent<Controller>().currentPosition = i;
			monster_transforms.Add(monster_spawn.transform);
			PartyOfMonsters.Add (monster_spawn.GetComponent<Controller>());

			// Create UI Text //
			GameObject UI = (GameObject)Instantiate(EnemyUIPrefab, EnemyUIPrefab.transform.position, Quaternion.identity);
			UI.transform.SetParent(canvas.transform);
			UI.transform.FindChild("Title").GetComponent<Text>().text = monster.title;
			string maxHealth = "/" + monster.max_health.ToString();
			UI.transform.FindChild("MaxHealth").GetComponent<Text>().text = maxHealth;
			UI.transform.FindChild("HealthSlider").GetComponent<Slider>().maxValue = monster.max_health;
			UI.transform.FindChild("HealthSlider").GetComponent<Slider>().value = monster.max_health;
			//UI.transform.FindChild("SpeedSlider").GetComponent<Slider>().maxValue = monster.dexterity;
			UI.transform.FindChild("SpeedSlider").GetComponent<Slider>().value = 0;
			UI.transform.FindChild("CurrentHealth").GetComponent<Text>().text = monster.current_health.ToString();
			UI.transform.FindChild("Level").GetComponent<Text>().text = monster.level.ToString();
			Transform prefab = EnemyUIPrefab.transform as Transform;
			UI.transform.localScale = prefab.localScale;
			UI.transform.localPosition = prefab.localPosition;
			UI.transform.localPosition = new Vector3(UI.transform.localPosition.x, UI.transform.localPosition.y + (-130 * i), 0);
			monster_spawn.GetComponent<Controller>().UIReference = UI;
			StartCoroutine(UISetup(UI, i));

			/*
			GameObject UI = (GameObject)Instantiate(TextUIPrefab, TextUIPrefab.GetComponent<RectTransform>().anchoredPosition3D, Quaternion.identity);
			UI.transform.SetParent(canvas.transform);
			UI.GetComponent<Text>().text = monster.title;
			RectTransform prefab = TextUIPrefab.transform as RectTransform;

			// Re-initialize values to prefab values, so that parenting does not distort initial scale //
			RectTransform newRectTransform = UI.transform as RectTransform;
			newRectTransform.anchoredPosition = prefab.anchoredPosition;
			newRectTransform.anchorMax = prefab.anchorMax;
			newRectTransform.anchorMin = prefab.anchorMin;
			newRectTransform.localRotation = prefab.localRotation;
			newRectTransform.localScale = prefab.localScale;
			newRectTransform.pivot = prefab.pivot;
			newRectTransform.sizeDelta = prefab.sizeDelta;

			// Set custom position //
			UI.GetComponent<RectTransform>().anchoredPosition3D = new Vector3(-10, (-100 * i) - 40, 0);
			// Set alpha to 0, then fade in //
			Color color = UI.GetComponent<Text>().color;
			color.a = 0.0f;
			UI.GetComponent<Text>().color = color;
			StartCoroutine(FadeOutText(UI, i));
			*/

			string title = monster.title;
			title = title.Replace(" ", string.Empty);
			title = title.Replace(",", string.Empty);
			monster_spawn.AddComponent(title);
			monster_spawn.GetComponent<EnemyAI>().SetSkills();
			List<CardData> thisInventory = monster_spawn.GetComponent<EnemyAI>().CompileCards();
			List<Transform> thisList = new List<Transform>();
			Factory.instance.Clear();
			for (int q = 0; q < thisInventory.Count; q++){
				thisInventory[q].level = q + 2;
				thisInventory[q].cardpower = Random.Range(1, 10);
				Material mat = Factory.instance.AbilityBake(thisInventory[q], monster.picture);
				GameObject ability_spawn = (GameObject)Instantiate(card_prefab, transform.GetChild(0).position, transform.GetChild(0).rotation);
				ability_spawn.GetComponent<CardScript>().Prepare(thisInventory[q].id, mat);
				thisList.Add(ability_spawn.transform);
				if(thisInventory[q].GetType() == typeof(MonsterAbility)){
					ability_spawn.AddComponent<WeaponController>();
					ability_spawn.GetComponent<WeaponController>().EnemyClone(thisInventory[q]); 
					ability_spawn.GetComponent<WeaponController>().player = PartyOfMonsters[i];
					ability_spawn.GetComponent<WeaponController>().dmgMod = 1.0f;
				}
			}
			Factory.instance.Clear();
			enemyCards.Add(thisList);
		}
	}
开发者ID:Kallen330,项目名称:Scripts,代码行数:88,代码来源:BattleManager.cs


注:本文中的Monster.ScaleToLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。