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;
    }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     e_anim = GetComponent <Animator>();
     ea     = GetComponent <EnemyAttribute>();
     agent  = GetComponent <NavMeshAgent>();
     FindTarget();
     hp = ea.GetHp();
 }
Пример #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;
     }
 }
Пример #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;
    }
Пример #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());
 }
Пример #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();
     }
 }
Пример #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);
    }
Пример #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;
 }
Пример #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();
         }
     }
 }
Пример #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);
    }
Пример #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]);
         }
     }
 }
Пример #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;
        }
    }
Пример #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);
     }
 }
Пример #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");
    }
Пример #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");
     }
 }
Пример #19
0
 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);
 }
Пример #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();
    }
Пример #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);
    }
Пример #22
0
 public bool Equals(EnemyAttribute other)
 {
     return(type == other.type);
 }
Пример #23
0
 public void Initialize(EnemyAttribute <TModuleType> attri, Transform transform)
 {
     this.enemyAttribute = attri;
     this.trans          = transform;
 }
Пример #24
0
 // Start is called before the first frame update
 protected override void Start()
 {
     base.Start();
     Registe(this);
     enemyAttribute = GetComponent <EnemyAttribute>();
 }
Пример #25
0
 public override void OnStart()
 {
     m_enemyAttribute = GetComponent <EnemyAttribute>();
 }