void Die() { LootDrop ld = GetComponent <LootDrop>(); ld.DropLoot(transform); Destroy(gameObject); }
void Awake() { if (anim == null) { anim = gameObject.GetComponent <Animator>(); } if (lootDrop == null) { lootDrop = gameObject.GetComponent <LootDrop>(); } dieOnce = false; currStatusCondition = StatusCondition.None; statusConditionTimer = 0.0f; tickCounter = 0.0f; if (burnStatusAnim != null) { burnStatusAnim.SetActive(false); } if (freezeStatusAnim != null) { freezeStatusAnim.SetActive(false); } }
private void Start() { statManager = StatManager.instance; lootDrop = GetComponent <LootDrop>(); animController = GetComponent <AIAnimationController>(); }
// Use this for initialization void Start() { mySpriteRenderer = GetComponent <SpriteRenderer>(); myBoxCollider2D = GetComponent <BoxCollider2D>(); myRigidbody2D = GetComponent <Rigidbody2D>(); myAudioSource = GetComponent <AudioSource>(); lootDrop = GetComponent <LootDrop>(); }
///////////////////////////// PRIVATE METHODS //////////////////////////////////////////// /// <summary> /// Returns a loot drop /// </summary> /// <param name="level"></param> /// <returns></returns> private LootDrop GetRandomDrop(int level) { var drop = SelectRandomItem(level); var result = new LootDrop(); result.item = drop.item; result.num = drop.GetRandomNumber(level); return(result); }
private void OnTriggerEnter(Collider other) { if (other.CompareTag("Loot")) { LootDrop lootDrop = other.GetComponent <LootDrop>(); Debug.Log(lootDrop.item.name); GameManager.current.PickupItem(lootDrop.item); other.gameObject.SetActive(false); Destroy(other.gameObject, 0.01f); } }
void Start() { enemyArm = transform.Find("EnemyArm").gameObject; RandomizeStartingWeapon(); if (enemyArm.transform.childCount > 0) { enemyWeapon = enemyArm.transform.GetChild(0).gameObject; } player = Player.instance; enemyMovementScript = gameObject.GetComponent <EnemyMovement>(); enemyWeaponScript = enemyArm.GetComponentInChildren <EnemyWeapon>(); lootDropScript = GetComponent <LootDrop>(); levelExitScript = GameObject.Find("LevelExitTrigger").GetComponent <LevelExit>(); cursor = MouseCursor.instance; gadgetScript = GameObject.Find("GadgetSlotPanel").GetComponent <Gadget>(); scannerInfoTooltip = gadgetScript.scannerInfoTooltip; spriteRenderer = GetComponent <SpriteRenderer>(); playerCapsuleCollider = player.GetComponent <CapsuleCollider2D>(); thisEnemyCollider = GetComponent <CapsuleCollider2D>(); hearingCollider = transform.Find("Hearing").GetComponent <CircleCollider2D>(); sightCollider = transform.Find("Sight").GetComponent <CircleCollider2D>(); lootBoxCollider = GetComponent <BoxCollider2D>(); lootBoxCollider.enabled = false; Physics2D.IgnoreCollision(thisEnemyCollider, playerCapsuleCollider); enemyStats.actualMaxHealth = enemyStats.maxHealth * enemyStats.startHealthPercent; enemyStats.Init(); actualMoney = Mathf.RoundToInt(Random.Range(minMoneyDrop, maxMoneyDrop)); anim = GetComponent <Animator>(); anim.SetFloat("health", enemyStats.currentHealth); /*if (statusIndicator != null) * { * statusIndicator.SetHealth(enemyStats.currentHealth, enemyStats.maxHealth); // Set health to max health at start * }*/ GameMaster.gm.onToggleUpgradeMenu += OnUpgradeMenuToggle; GameMaster.gm.onTogglePauseMenu += OnPauseMenuToggle; audioManager = AudioManager.instance; if (audioManager == null) { Debug.LogError("No audio manager in scene."); } }
private void MakeLoot() { if (thisLoot != null) { LootDrop current = thisLoot.LootsDrop(); if (current != null) { Instantiate(current.gameObject, transform.position, Quaternion.identity); } } }
protected void LootDropTableGUI(string lootId, Loot l) { GUILayout.BeginVertical("Box", GUILayout.Width(400)); for (int i = 0; i < l.dropTable.Count; i++) { LootDrop drop = l.dropTable[i]; LootDropGUI(lootId, l, drop, i); } if (GUILayout.Button("+")) { l.dropTable.Add(new LootDrop()); } GUILayout.EndVertical(); }
// Trigger the destroy public override void Attacked(Vector3 attackVector) { // Protect against multiple hit loot table objects? But also increment once because Random.Range(int, int) is (inc, exc)! if (!m_hasInclusifiedTopRange) { m_maxDrops++; m_hasInclusifiedTopRange = true; } // Drops items int drops = Random.Range(m_minDrops, m_maxDrops); // Get the loot table length int tableLength = m_lootTable.GetLootTableLength(); for (int i = 0; i < drops; ++i) { // Percentage (RNG) float perc = Random.Range(0.0f, 100.0f); // Grab all the drops possible List <GameObject> candidateDrops = new List <GameObject> (); // Get all the possible drops for this percentage for (int c = 0; c < tableLength; ++c) { LootDrop candidate = m_lootTable.GetLootObject(c); if (candidate != null) { if (perc <= candidate.LootChance) { // EG: Lootchance 90, our percentage was 67, it would be added, if our perc was 95 it would not. (psuedo 90%) candidateDrops.Add(candidate.LootPrefab); } } } // Spawn the loot if (candidateDrops.Count > 0) { Instantiate(candidateDrops [Random.Range(0, candidateDrops.Count)], transform.position + m_spawnOffset, Quaternion.identity); } } // Call cleanup and base destructable code base.Attacked(attackVector); }
public override void _Ready() { turnManager = GetNode("/root/TurnManager") as TurnManager; grid = GetTree().GetRoot().GetNode("Game/Grid") as Grid; game = GetTree().GetRoot().GetNode("Game") as Game; player = GetTree().GetRoot().GetNode("Game/Player") as Player; console = GetTree().GetRoot().GetNode("Game/CanvasLayer/GUI/Console") as Console; stats = GetNode("Stats") as Stats; attackTimer = GetNode("AttackTimer") as Timer; lootDrop = GetNode("LootDrop") as LootDrop; turnManager.Turns.Add(this); pathfinding.InitializePathfinding(grid, player); SpawnInRandomPosition(); gridPosition = new Vector2(Mathf.FloorToInt(Position.x / 16), Mathf.FloorToInt(Position.y / 16)); }
// Use this for initialization void Start() { // this._audioSources = gameObject.GetComponents<AudioSource> (); // this._deathSound = this._audioSources [1]; // this._hitSound = this._audioSources [2]; enableTargetingScript = GetComponent<EnemyTargeting> (); enableShootingScript = GetComponent<EnemyFire> (); droppings = GetComponent<LootDrop> (); //_currentPlayerLocation = GameObject.FindGameObjectWithTag("Player").transform.position; this._Reset (); ///////////////////////////////// /// Stats Script diffuclty = 0; speed = 5; //player = GameObject.Find ("player"); //this.playerStats = player.GetComponent<PlayerStats>(); //otherDamage = playerStats.bulletDamage; maxHealth = 100; currentHealth = maxHealth; armour = 0; maxShield = 0; currentShield = maxShield; otherDamage = 50; damage = 10; }
void Awake() { currentHealth = maxHealth; material = GetComponent <Renderer>().material; loot = GetComponent <LootDrop>(); }
protected override GameObject Create() { long id = currentTargetLevelData.monster.Id; GameObject agent = Instantiate(Resources.Load <GameObject>("Prefab/Monster/" + id), transform); LootDrop lootDrop = GetComponentInParent <LootDrop>(); DamageTaker damageTaker = GetComponentInParent <DamageTaker>(); UnitInfo unitInfo = GetComponentInParent <UnitInfo>(); AIBehaviors ai = GetComponentInParent <AIBehaviors>(); CharacterAnimator characterAnimator = GetComponentInParent <CharacterAnimator>(); Node node = (Node)args[0]; //OffensiveState offensiveState = ai.GetState<OffensiveState>(); //offensiveState.currentNode = node; //offensiveState.GetTrigger<WithinDistanceTrigger>().center = transform; PatrolState patrolState = ai.GetState <PatrolState>(); patrolState.SetPatrolPoints(node.transform.parent); patrolState.GetTrigger <WithinDistanceTrigger>().center = transform; //AttackState attackState = ai.GetState<AttackState>(); //attackState.GetTrigger<BeyondDistanceTrigger>().center = transform; //动画 Animator animator = agent.GetComponent <Animator>(); RuntimeAnimatorController runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Model/" + id + "/Animation/Controller"); if (runtimeAnimatorController != null) { animator.runtimeAnimatorController = runtimeAnimatorController; } characterAnimator.anim = animator; damageTaker.healthBar = agent.transform.Find("HealthBar"); damageTaker.sprite = GetComponentInChildren <SpriteRenderer>(); //信息 unitInfo.unitName = currentTargetLevelData.monster.Name; unitInfo.primaryText = currentTargetLevelData.monster.LootDropped.ToString(); unitInfo.secondaryText = currentTargetLevelData.monster.PhyAttackMin + "-" + currentTargetLevelData.monster.PhyAttackMax; //属性 lootDrop.lootDropped = currentTargetLevelData.monster.LootDropped; UnityEngine.Object alignment = Resources.Load("Data/Alignment/EnemyAlignment"); if (this.configuration.alignment == null) { this.configuration.alignment = new SerializableIAlignmentProvider(); this.configuration.alignment.unityObjectReference = alignment; } else { this.configuration.alignment.unityObjectReference = alignment; } //总开关 damageTaker.Initialize(); ai.Initialize(); this.gameObject.name = id.ToString(); return(agent); }
protected void LootDropGUI(string lootId, Loot l, LootDrop drop, int index) { string errorString; GUILayout.BeginVertical(); GUILayout.BeginHorizontal("Box"); // DROP ROW - REMOVE BUTTON if (GUILayout.Button("-", GUILayout.Width(15), GUILayout.Height(15))) { if (EditorUtility.DisplayDialog("Delete Drop Row", "Are you sure?", "Delete", "Cancel")) { l.dropTable.Remove(drop); } } // DROP ROW - PREFAB NAME drop.prefabName = GUILayout.TextField(drop.prefabName, GUILayout.Width(150)); // DROP ROW - QUANTITY bool quantityValid = false; string quantityKey = lootId + "Quantity" + index; if (!temporaryStrings.ContainsKey(quantityKey)) { temporaryStrings[quantityKey] = drop.quantity.ToString(); } GUILayout.Label("Quantity: "); temporaryStrings[quantityKey] = GUILayout.TextField(temporaryStrings[quantityKey], GUILayout.Width(25)); int result = 0; if (int.TryParse(temporaryStrings[quantityKey], out result)) { drop.quantity = (uint)Mathf.Max(0, result); quantityValid = true; } // DROP ROW - WEIGHT bool weightValid = false; string weightKey = lootId + "Weight" + index; if (!temporaryStrings.ContainsKey(weightKey)) { temporaryStrings[weightKey] = drop.weight.ToString(); } GUILayout.Label("Weight: "); temporaryStrings[weightKey] = GUILayout.TextField(temporaryStrings[weightKey], GUILayout.Width(40)); if (int.TryParse(temporaryStrings[weightKey], out result)) { drop.weight = (uint)Mathf.Max(0, result); weightValid = true; } if (weightValid && quantityValid && drop.IsValid(out errorString, prefabList)) { GUILayout.Label("✓"); } else { GUILayout.Label("✖"); } GUILayout.EndHorizontal(); if (errorString != null && !errorString.Trim().Equals("")) { GUILayout.Label("<color=red>" + errorString + "</color>", richTextStyle); } GUILayout.EndVertical(); }