public override void OnAttack(Transform targetTransform, Color color, GameObject effect = null, GameObject projectile = null, PostEffect.PostEffectType pEffect = PostEffect.PostEffectType.NONE) { GameObject temp = Instantiate(effect, new Vector3(targetTransform.position.x, targetTransform.position.y, targetTransform.position.z), Quaternion.identity) as GameObject; GameObject tArea = Instantiate(Character.instance.meleeAttackArea, new Vector3(targetTransform.position.x, targetTransform.position.y, targetTransform.position.z), Quaternion.identity) as GameObject; AttackAreaDamage Area = tArea.GetComponent <AttackAreaDamage>(); Area.damage = Character.instance.weapon.GetDamage(); Area.typesToAttack.Add("Enemy"); Area.typesToAttack.Add("Enemy"); Area.postEffect = pEffect; temp.GetComponent <SpriteRenderer>().color = color; Vector3 newLocalScale = temp.transform.localScale; if (Character.instance.transform.localScale.x > 0) { newLocalScale.x = 1f - 0.3f; } else { newLocalScale.x = -1f + 0.3f; } temp.transform.localScale = newLocalScale; }
// Start is called before the first frame update protected override void Awake() { base.Awake(); id = idCounter++; Companion tComp = this.gameObject.GetComponent <Companion>(); HeaderUI tHeader = CanvasScript.instance.headerUI.GetComponent <HeaderUI>(); tHeader.companionIcons[tComp.id].gameObject.SetActive(true); // tHeader.companionFills[tComp.id].gameObject.SetActive(true); tHeader.images[tComp.id].gameObject.SetActive(true); tHeader.companionIcons[tComp.id].sprite = tComp.actorIcon; // tHeader.companionFills[tComp.id].normalizedValue = tComp.health / this.maxHealth; detector = GetComponentInChildren <SpotEnemy>(); this.actorType = NPC.ActorType.COMPANION; typesToTarget.Add(NPC.ActorType.MOB); AttackAreaDamage temp = hitPoint.GetComponent <AttackAreaDamage>(); temp.damage = this.damage; this.SetState(new IdleState(this.gameObject)); }
// Start is called before the first frame update void Start() { this.items = new Item[3]; detector = GetComponentInChildren <SpotEnemy>(); this.actorType = NPC.ActorType.MOB; typesToTarget.Add(NPC.ActorType.COMPANION); typesToTarget.Add(NPC.ActorType.PLAYER); AttackAreaDamage temp = hitPoint.GetComponent <AttackAreaDamage>(); temp.damage = this.damage; //temp.typesToAttack = new string[2] { "Player", "Companion" }; // this.state = NPC.State.PATROL; this.SetState(new PatrolState(this.gameObject)); //if (this.type == NPCType.RANGED) //{ // projectile.GetComponent<Projectile>().typesToAttack.Add("Player"); // projectile.GetComponent<Projectile>().typesToAttack.Add("Companion"); //} // Randomly Create Weapons for (int i = 0; i < 2; ++i) { int itemIconMin = 0; int itemIconMax = 0; int attributeTypeMax = 3; int skillProjectileId = 0; int skillTypeMin = 0; int skillTypeMax = 0; int skillIcon = 0; int itemIcon; int attributeType; string baseName = "Weapon"; int skillType = 0; int wepType = Random.Range(0, 2); Random.Range(0, attributeTypeMax); attributeType = Random.Range(0, attributeTypeMax); GameManager.Pair skillProj = new GameManager.Pair(0, 0); switch (wepType) { case 0: itemIconMin = 6; itemIconMax = 12; skillTypeMin = 0; skillTypeMax = 1; baseName = "Sword"; break; case 1: itemIconMin = 0; itemIconMax = 5; skillTypeMin = 1; skillTypeMax = 3; baseName = "Bow"; break; default: break; } skillType = Random.Range(skillTypeMin, skillTypeMax); itemIcon = Random.Range(itemIconMin, itemIconMax); skillIcon = skillType; if (skillType > 0) { skillProjectileId = Random.Range(0, 2); } else { skillProjectileId = skillType; } itemIcon = Random.Range(itemIconMin, itemIconMax); items[i] = (GameManager.instance.weaponFactory.CreateWeapon(new WeaponFactory.WeaponEssentials((WeaponFactory.AttributeType)attributeType, (Weapon.ClassType)wepType, GameObjectContainers.instance.GetAttackEffect(0), 10, (Weapon.SkillClassType)skillType, GameObjectContainers.instance.GetAttackEffect(1), skillType > 0 ? GameObjectContainers.instance.GetArrowProjectile(skillProjectileId) : GameObjectContainers.instance.GetMagicProjectile(skillProjectileId), wepType == 1 ? GameObjectContainers.instance.GetArrowProjectile(0) : null, GameObjectContainers.instance.GetSkillIcon(skillIcon)), new ItemFactory.ItemEssentials(GameObjectContainers.instance.GetItemIcon(itemIcon), (int)(Random.Range(0f, 1f) * 30), GameManager.instance.currentLevel, baseName, 0, true, new Vector2(1, 1), true, Item.ItemType.WEAPON, null, null, Character.instance))); } items[2] = (GameManager.instance.potionFactory.CreatePotion(new PotionFactory.PotionEssentials(Potion.PotionType.HEALTH, 10 * GameManager.instance.currentLevel), new ItemFactory.ItemEssentials(GameObjectContainers.instance.GetPotionIcon(0), (int)(10 * GameManager.instance.currentLevel * 0.3f), GameManager.instance.currentLevel, "Health Potion", 1, false, new Vector2(1, 1), true, Item.ItemType.POTION, null, null, null))); }
public void FinishAttack() { GameObject tempObject = null; if (type == NPCType.MELEE) { tempObject = Instantiate(hitPoint, new Vector3(attackPoint.transform.position.x, attackPoint.transform.position.y, attackPoint.transform.position.z), Quaternion.identity) as GameObject; } else if (type == NPCType.RANGED) { tempObject = Instantiate(projectile, new Vector3(shootPoint.transform.position.x, shootPoint.transform.position.y, shootPoint.transform.position.z), Quaternion.identity) as GameObject; } if (type == NPCType.RANGED) { Projectile tProjectile = tempObject.GetComponent <Projectile>(); tProjectile.owner = this; tProjectile.damage = (int)(this.damage * (1f + GameManager.instance.currentLevel * 0.3f)); Vector3 newLocalScale = tempObject.transform.localScale; if (this.transform.localScale.x > 0) { if (tProjectile != null && tProjectile.xScale != 0) { newLocalScale.x = this.transform.localScale.x + tProjectile.xScale; } else { newLocalScale.x = this.transform.localScale.x - 0.3f; } } else { if (tProjectile != null && tProjectile.xScale != 0) { newLocalScale.x = this.transform.localScale.x - tProjectile.xScale; } else { newLocalScale.x = this.transform.localScale.x + 0.3f; } } tempObject.transform.localScale = newLocalScale; tempObject.GetComponent <Projectile>().SetSpeed(this.transform.localScale.x * 7.0f); if (this.actorType == ActorType.MOB) { tProjectile.typesToAttack.Add("Player"); tProjectile.typesToAttack.Add("Companion"); } else if (this.actorType == ActorType.COMPANION) { tProjectile.typesToAttack.Add("Enemy"); tProjectile.typesToAttack.Add("Enemy"); } } else if (type == NPCType.MELEE) { AttackAreaDamage area = tempObject.GetComponent <AttackAreaDamage>(); area.owner = this; area.damage = (int)(this.damage * (1f + GameManager.instance.currentLevel * 0.3f)); area.transform.localScale = new Vector3(this.transform.localScale.x, this.transform.localScale.y, this.transform.localScale.z); if (this.actorType == ActorType.MOB) { area.typesToAttack.Add("Player"); area.typesToAttack.Add("Companion"); } else if (this.actorType == ActorType.COMPANION) { area.typesToAttack.Add("Enemy"); area.typesToAttack.Add("Enemy"); } } if (!alternativeRGB.a.Equals(0.0f)) { tempObject.GetComponentInChildren <SpriteRenderer>().color = alternativeRGB; } audioSource.PlayOneShot(clipToPlay); }