public override bool IsConditionValid()
 {
     Collider2D[] lstHit = Physics2D.OverlapCircleAll(transform.position, CircleRadius, CheckMask);
     if (lstHit.Length > 0)
     {
         EnemyAttribute enemyAttribute = GetComponent <EnemyAttribute>();
         if (enemyAttribute)
         {
             GameObject h = lstHit[0].gameObject;
             foreach (Collider2D c in lstHit)
             {
                 if (Vector2.Distance(transform.position, c.transform.position) < Vector2.Distance(transform.position, h.transform.position) && gameObject != c.gameObject)
                 {
                     h = c.gameObject;
                 }
             }
             if (gameObject != h)
             {
                 enemyAttribute.target = h;
             }
             else
             {
                 return(false);
             }
         }
         return(true);
     }
     return(false);
 }
    // Update is called once per frame
    void Update()
    {
        if (SpawnTimer > 0.0f)
        {
            SpawnTimer -= Time.fixedDeltaTime;
        }
        if (Vector3.Distance(transform.position, Player.transform.position) < DetectionDist)
        {
            if (SpawnedEnemyAmt < enemyNumber)
            {
                StartCoroutine("Spawner");
            }
        }
        else
        {
            StopCoroutine("Spawner");
        }

        foreach (GameObject n in EnemyList)
        {
            if (n == null)
            {
                EnemyList.Remove(n);
                SpawnedEnemyAmt--;
            }
        }

        foreach (EnemyAttribute n in enemyAttributeList.enemysattribute)
        {
            if (n.EnemyName == EnemyPrefab.name)
            {
                eA = n.Clone();
            }
        }
    }
    public override void BuildAttribute()
    {
        //1、实例化数值属性
        CharacterAttribute attribute = new EnemyAttribute(FactoryManger.AttributeFactory.GetCharShareAttribute(base.CharacterType), base.Lv);

        base.Character.Attribute = attribute;
    }
Example #4
0
 // Use this for initialization
 void Start()
 {
     e_anim = GetComponent <Animator>();
     ea     = GetComponent <EnemyAttribute>();
     agent  = GetComponent <NavMeshAgent>();
     FindTarget();
     hp = ea.GetHp();
 }
Example #5
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Enemy" && playerAttack.isAttacking)
     {
         EnemyAttribute temp = other.gameObject.GetComponent <EnemyAttribute>();
         temp.TakeDamage(damage + playerAttribute.atk);
         playerAttack.isAttacking = false;
     }
 }
Example #6
0
    public override void AddCharacterAttr()
    {
        CharacterBaseAttr baseAttr = FactoryManager.attrFactory.GetCharacterBaseAttr(mType);

        mPrefabName = baseAttr.prefabName;
        ICharacterAttribute attr = new EnemyAttribute(new EnemyAttrStrategy(), mLevel, baseAttr);

        mCharacter.Attr = attr;
    }
Example #7
0
 void Start()
 {
     winPanel.SetActive(false);
     losePanel.SetActive(false);
     enemyAttribute = GetComponent <EnemyAttribute>();
     Gun1.onClick.AddListener(() => Shop.instance.PurchaseStandardTurrets());
     Gun2.onClick.AddListener(() => Shop.instance.PurchaseAnotherTurrets());
     Gun3.onClick.AddListener(() => Shop.instance.PurchaseSpecialTurrets());
 }
Example #8
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("CheckPoint"))
     {
         GameManager.towerPoint -= 1;
         GameObject     hitCheck = this.gameObject;
         EnemyAttribute hit      = hitCheck.GetComponent <EnemyAttribute>();
         hit.GetCheckPoint();
     }
 }
Example #9
0
    public void InitializeGenerator(EnemyAttribute <TModuleType> enemyAttribute)
    {
        float itemQuantityPercent = enemyAttribute.TargetAttribute.attributes[(int)e_entityAttribute.Item_Quantity_Percent] * enemyAttribute.attributes[(int)e_entityAttribute.Item_Quantity_Percent] * 0.0001f;
        float itemRarityPercent   = enemyAttribute.TargetAttribute.attributes[(int)e_entityAttribute.Item_Rarity_Percent] * enemyAttribute.attributes[(int)e_entityAttribute.Item_Rarity_Percent] * 0.0001f;
        float goldAmountPercent   = enemyAttribute.TargetAttribute.attributes[(int)e_entityAttribute.Gold_Amount_Percent] * enemyAttribute.attributes[(int)e_entityAttribute.Gold_Amount_Percent] * 0.0001f;
        float goldQuantityPercent = enemyAttribute.TargetAttribute.attributes[(int)e_entityAttribute.Gold_Quantity_Percent] * enemyAttribute.attributes[(int)e_entityAttribute.Gold_Quantity_Percent] * 0.0001f;
        float goldRarityPercent   = enemyAttribute.TargetAttribute.attributes[(int)e_entityAttribute.Gold_Rarity_Percent] * enemyAttribute.attributes[(int)e_entityAttribute.Gold_Rarity_Percent] * 0.0001f;

        this.lootAttribute.Initialize(itemQuantityPercent, itemRarityPercent, goldAmountPercent, goldQuantityPercent, goldRarityPercent);
    }
Example #10
0
 public void UpdateUI(EnemyAttribute ea)
 {
     this.gameObject.SetActive(true);
     timer        = 0f;
     icon.texture = ea.icon;
     Hp.value     = (int)Mathf.Floor((100 * ea.currentHealth / ea.startingHealth));
     Hp.transform.GetChild(2).GetComponent <Text>().text = ea.currentHealth.ToString() + " / " + ea.startingHealth.ToString();
     Mp.value = (int)Mathf.Floor((100 * ea.currentMp / ea.startingMp));
     Mp.transform.GetChild(2).GetComponent <Text>().text = ea.currentMp.ToString() + " / " + ea.startingMp.ToString();
     Lv.text = "Lv " + ea.currentLevel;
 }
Example #11
0
 // Use this for initialization
 void Start()
 {
     Canvas             = GameObject.FindGameObjectWithTag("UI");
     enemyAttributeList = GameObject.FindGameObjectWithTag("GameManager").GetComponent <EnemyAttributeListScript>();
     foreach (EnemyAttribute n in enemyAttributeList.enemysattribute)
     {
         if (n.EnemyName == gameObject.name)
         {
             eA = n.Clone();
         }
     }
 }
Example #12
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Enemy"))
     {
         GameObject hitEffect = Instantiate(HitParticle, transform.position, transform.rotation);
         hitEffect.transform.SetParent(storage.transform);
         GameObject     hitEnemy = other.gameObject;
         EnemyAttribute stat     = hitEnemy.GetComponent <EnemyAttribute>();
         stat.GetHit(damage, penetration);
         Destroy(gameObject);
         Destroy(hitEffect, 2f);
     }
 }
    public EnemyAttribute Clone()
    {
        EnemyAttribute newEnemyAttribute = new EnemyAttribute();

        newEnemyAttribute.EnemyName          = this.EnemyName;
        newEnemyAttribute.EnemyHealth        = this.EnemyHealth;
        newEnemyAttribute.EnemyDamage        = this.EnemyDamage;
        newEnemyAttribute.EnemyMovementSpeed = this.EnemyMovementSpeed;
        newEnemyAttribute.EnemyAttackRange   = this.EnemyAttackRange;
        newEnemyAttribute.EnemyAttackSpeed   = this.EnemyAttackSpeed;

        return(newEnemyAttribute);
    }
Example #14
0
 public void SwapAllAttributes(EnemyAttribute otherAttributes)
 {
     if (otherAttributes.GetType() != this.GetType())
     {
         return;
     }
     else
     {
         for (int i = 0; i < values.Count; i++)
         {
             values[i].Swap(otherAttributes.values[i]);
         }
     }
 }
Example #15
0
    public void Addtribute(EnemyAttribute attribute)
    {
        if (attribute.type == AttributeType.SHIELD && attribute.amount == 0)
        {
            return;
        }

        attributes.Add(attribute);

        if (attribute.type == AttributeType.SHIELD || attribute.type == AttributeType.TIME_SHIELD)
        {
            for (int i = 0; i < attribute.amount; i++)
            {
                Shield s = Instantiate(shield, transform.position, Quaternion.identity, transform).GetComponent <Shield>();

                if (attribute.type == AttributeType.TIME_SHIELD)
                {
                    s.SetTimeOnly();
                }

                shields.Push(s);

                s.transform.localScale = (1.6f + 0.3f * (shields.Count)) * new Vector2(1, 1);

                if (tag == "SnapEnemy")
                {
                    s.transform.localScale = (1.3f + 0.3f * (shields.Count)) * new Vector2(1, 1);
                }

                s.transform.localEulerAngles = Vector3.forward * 20f * (shields.Count);

                s.parent = this;
            }
        }

        if (attribute.type == AttributeType.TIME_ONLY)
        {
            GetComponent <SpriteRenderer>().color = Color.green;
        }

        if (attribute.type == AttributeType.REFLECT)
        {
            Shield s = Instantiate(reflect, transform.position, Quaternion.identity, transform).GetComponent <Shield>();
            s.transform.localScale = 1.6f * new Vector2(1, 1);

            s.parent = this;
        }
    }
Example #16
0
 void OnTriggerEnter(Collider other)
 {
     //if (other.tag == "Enemy" && playerAttack.isAttacking)
     if (other.tag == "Enemy")
     {
         EnemyAttribute temp = other.gameObject.GetComponent <EnemyAttribute>();
         temp.TakeDamage(playerAttribute.atk / 2);
         es.UpdateUI(temp);
         Destroy(gameObject);
         return;
     }
     if (other.tag != "Player")
     {
         ridigB.velocity   = Vector3.zero;
         ridigB.useGravity = false;
         //ridigB.isKinematic = true;
         isColl = true;
         Destroy(gameObject, 1f);
     }
 }
Example #17
0
    //below for warrior
    void Attack()
    {
        Vector3    forward = transform.TransformDirection(Vector3.forward);
        Vector3    origin  = transform.position + new Vector3(0.0f, 1.0f, 0.0f);;
        RaycastHit hit;

        if (Physics.Raycast(origin, forward, out hit, 2))
        {
            //Debug.DrawLine(Camera.main.transform.position, hit.transform.position, Color.red, 0.1f, true);
            //Debug.Log(hit.transform.name);
            if (hit.transform.gameObject.tag == "Enemy")
            {
                EnemyAttribute ea = hit.transform.gameObject.GetComponent <EnemyAttribute>();
                ea.TakeDamage(GetShortRangeDamage(pa.atk, 0, ea.defence));
                es.UpdateUI(ea);
            }
        }
        timer = 0f;
        GameManager.AudioManager.GetComponent <BGMcontrol>().Playsound("SwordAttack");
        anim.SetTrigger("Attack");
    }
Example #18
0
 void AttackByCyclone(int level)
 {
     if (pa.ConsumeMP(50))
     {
         Collider[] hitColliders = Physics.OverlapSphere(new Vector3(transform.position.x, transform.position.y + 1.0f, transform.position.z), 3);
         int        i            = 0;
         while (i < hitColliders.Length)
         {
             if (hitColliders[i].gameObject.tag == "Enemy")
             {
                 EnemyAttribute ea = hitColliders[i].transform.gameObject.GetComponent <EnemyAttribute>();
                 ea.TakeDamage(GetShortRangeDamage(pa.atk, Mathf.FloorToInt(pa.atk * (level / 10)), ea.defence));
                 es.UpdateUI(ea);
             }
             i++;
         }
         timer = 0f;
         GameManager.AudioManager.GetComponent <BGMcontrol>().Playsound("SwordAttack");
         anim.SetTrigger("AttackBySkill0");
     }
 }
 public void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         Debug.Log("forward");
         player          = GameManager.player;
         playerAttribute = player.GetComponent <PlayerAttribute>();
         es = SceneManager.GetSceneByName("UI").GetRootGameObjects()[0].transform.GetChild(11).GetComponent <EnemyStatus>();
         EnemyAttribute temp = col.gameObject.GetComponent <EnemyAttribute>();
         if (type == "Firebolt")
         {
             temp.TakeDamage(pa.GetLongRangeDamage(playerAttribute.atk, 0, temp.defence, Mathf.FloorToInt(Vector3.Distance(temp.transform.position, GameManager.player.transform.position))));
         }
         else
         {
             temp.TakeDamage(pa.GetLongRangeDamage(playerAttribute.atk, playerAttribute.Skill[0], temp.defence, Mathf.FloorToInt(Vector3.Distance(temp.transform.position, GameManager.player.transform.position))));
         }
         es.UpdateUI(temp);
     }
     //CollisionHandler.HandleCollision(gameObject, col);
 }
Example #20
0
    public override void OnInspectorGUI()
    {
        enemyAttribute = serializedObject.targetObject as EnemyAttribute;

        if (enemyAttribute.values.Count > 0)
        {
            foreach (IEnemyValue iev in enemyAttribute.values)
            {
                EnemyValue <int> intval = iev as EnemyValue <int>;
                if (intval != null)
                {
                    EditorGUILayout.SelectableLabel("" + intval.Value);
                    EditorGUILayout.IntField(intval.Value);
                    continue;
                }
                EnemyValue <float> floatval = iev as EnemyValue <float>;
                if (floatval != null)
                {
                    EditorGUILayout.SelectableLabel("" + floatval.Value);
                    EditorGUILayout.FloatField(floatval.Value);
                    continue;
                }
                EnemyValue <string> stringval = iev as EnemyValue <string>;
                if (stringval != null)
                {
                    EditorGUILayout.SelectableLabel("" + stringval.Value);
                    EditorGUILayout.TextField(stringval.Value);
                    continue;
                }
            }
        }

        DrawDefaultInspector();
        if (GUILayout.Button("Swap all attributes"))
        {
            enemyAttribute.SwapAllAttributes(enemyAttribute.swapWith);
        }

        serializedObject.ApplyModifiedProperties();
    }
Example #21
0
    void OnTriggerEnter(Collider other)
    {
        //Debug.Log(other.name+" "+other.tag);
        //if (other.tag == "Enemy" && playerAttack.isAttacking)
        if (other.tag == "Enemy")
        {
            EnemyAttribute temp        = other.gameObject.GetComponent <EnemyAttribute>();
            float          skillDamage = 0;
            switch (arrowType)
            {
            case "Normal":
                skillDamage = 0;
                break;

            case "Triple":
                skillDamage = (skillLevel / 10) / 3;
                break;

            case "Jump":
                skillDamage = skillLevel / 10;
                break;
            }
            temp.TakeDamage(player.GetComponent <PlayerAttack>().GetLongRangeDamage(playerAttribute.atk, Mathf.FloorToInt(playerAttribute.atk * skillDamage), temp.defence, Mathf.FloorToInt(Vector3.Distance(player.transform.position, temp.transform.position))));
            es.UpdateUI(temp);
            Destroy(gameObject);
            return;
        }

        if (other.tag == "Player")
        {
            return;
        }

        ridigB.velocity    = Vector3.zero;
        ridigB.useGravity  = false;
        ridigB.isKinematic = true;
        isColl             = true;
        Destroy(gameObject, 1f);
    }
Example #22
0
 public bool Equals(EnemyAttribute other)
 {
     return(type == other.type);
 }
Example #23
0
 public void Initialize(EnemyAttribute <TModuleType> attri, Transform transform)
 {
     this.enemyAttribute = attri;
     this.trans          = transform;
 }
Example #24
0
 // Start is called before the first frame update
 protected override void Start()
 {
     base.Start();
     Registe(this);
     enemyAttribute = GetComponent <EnemyAttribute>();
 }
 public override void OnStart()
 {
     m_enemyAttribute = GetComponent <EnemyAttribute>();
 }