static readonly int StartRow = 4;               //根据表格中定义, 开始读取的行数(第五行开始)



    //==========》 读取Enemy配置数据
    public static EnemyProps[] CreateEnemyData(string filePath, string tableName)
    {
        //获得表数据
        int columnNum = 0, rowNum = 0;
        DataRowCollection collect = ReadExcel(filePath, tableName, ref columnNum, ref rowNum);

        EnemyProps[] array = new EnemyProps[rowNum - StartRow];
        for (int i = StartRow; i < rowNum; i++)
        {
            EnemyProps enemy = new EnemyProps();
            //解析每列的数据
            //enemy.id = GameDataUtils.ReadInt(collect[i][0]);
            //enemy.enmeyType = (EnemyType)GameDataUtils.ReadInt(collect[i][0]);
            //enemy.enemyName = collect[i][1].ToString();
            //enemy.des = collect[i][2].ToString();
            //enemy.iconPath = collect[i][3].ToString();
            //enemy.checkRange = GetDistance(collect[i][4]);
            //enemy.attack = GameDataUtils.ReadFloat(collect[i][5]);
            //enemy.adRange = GetDistance(collect[i][6]);
            //enemy.adSpeed = GameDataUtils.ReadFloat(collect[i][7]);
            //enemy.adInterval = GameDataUtils.ReadFloat(collect[i][8]);
            //enemy.moveSpeed = GameDataUtils.ReadFloat(collect[i][9]) / 100;
            //enemy.defense = GameDataUtils.ReadFloat(collect[i][10]);
            //enemy.hp = GameDataUtils.ReadFloat(collect[i][11]);
            //enemy.exp = GameDataUtils.ReadFloat(collect[i][12]);

            array[i - StartRow] = enemy;
        }
        return(array);
    }
Esempio n. 2
0
 void InitEnemyCfg()
 {
     enemyDic.Clear();
     for (int i = 0; i < enemyArray.Length; i++)
     {
         int        enemyType  = enemyArray[i].id;
         EnemyProps enemyProps = enemyArray[i];
         enemyDic.Add(enemyType, enemyProps);
     }
 }
Esempio n. 3
0
    public EnemyProps GetEnemyPropsWithType(int type)
    {
        EnemyProps enemyProps = new EnemyProps();

        if (enemyDic.TryGetValue(type, out enemyProps))
        {
            return(enemyProps);
        }
        Debug.LogError("找不到目标===》" + type);
        return(enemyProps);
    }
    // Update is called once per frame
    void Update()
    {
        EnemyProps proprieta = GetComponentInParent <EnemyProps>();

        temporanea = proprieta.wasAlive;

        if (temporanea == false)
        {
            Spawn();
        }

        temporanea = true;
    }
Esempio n. 5
0
    void Awake()
    {
        Camera.main.transparencySortMode = TransparencySortMode.Orthographic;

        healthBarWidth = healthBar.transform.localScale.x;  // Set initial width of health bar

        mob = transform.parent.gameObject;
        transform.parent = null;    // IMPORTANT. Detatch healthbar from player to prevent rotation

        // Determine if bar is attached to enemy or player and use appropriate health stats
        if (mob.tag == "Player")
        {
            curHP = PlayerProps.currentHealth;
            maxHP = PlayerProps.maxHealth;
        }
        else
        {
            enemy = mob.GetComponent <EnemyProps>();
            curHP = enemy.currentHealth;
            maxHP = EnemyProps.maxHealth;
        }

        transform.localScale = new Vector3(0.1f, 0.1f, 0.005f);    // Set size of health bar
    }
    void Explode()
    {
        //Debug.Log("BOOM!");

        Instantiate(explosionEffect, transform.position, transform.rotation);

        Collider[] colliders = Physics.OverlapSphere(transform.position, weaponProps._granadeRadius);

        foreach (Collider nearbyObject in colliders)
        {
            Rigidbody rb = nearbyObject.GetComponent <Rigidbody>();

            //Debug.Log("prima del raycast");

            if (rb != null)
            {
                if (nearbyObject.GetComponent <PlayerProps>() != null || nearbyObject.GetComponent <EnemyProps>() != null)
                {
                    RaycastHit raycast;

                    if (Physics.Linecast(transform.position, rb.transform.position, out raycast, layerMask.value))
                    {
                        //Debug.Log("dentro il raycast");

                        float damageMultiplier;

                        //proporzione per rendere da 0 a 1 il raggio dell'espolione, rendendola una percentuale
                        damageMultiplier = 1 - (raycast.distance / weaponProps._granadeRadius);


                        if (nearbyObject.GetComponent <PlayerProps>() != null)
                        {
                            PlayerProps player = nearbyObject.GetComponent <PlayerProps>();

                            //Debug.LogFormat("multiplayer danno player = {0}", damageMultiplier);

                            //Debug.LogFormat("distanza player = {0}", raycast.distance);

                            //Debug.Log("danno al giocatore");

                            player.GetDamage((weaponProps._damage * damageMultiplier) * 0.1F);
                        }

                        if (nearbyObject.GetComponent <EnemyProps>() != null)
                        {
                            EnemyProps enemy = nearbyObject.GetComponent <EnemyProps>();

                            //Debug.LogFormat("multiplayer danno nemico = {0}", damageMultiplier);

                            //Debug.LogFormat("distanza nemico = {0}", raycast.distance);

                            //Debug.Log("danno al nemico");

                            enemy.GetDamage(weaponProps._damage * damageMultiplier);
                        }
                    }
                }

                //Debug.Log("dopo il raycast");

                // propaga forza dell'esplosione agli oggetti vicini
                rb.AddExplosionForce(weaponProps._granadExplosionForce, transform.position, weaponProps._granadeRadius);

                //cancella l'oggetto
                Destroy(gameObject);
            }
        }
    }
Esempio n. 7
0
 private void KillEnemy(EnemyProps enemy)
 {
     enemy.GetDamage(enemy.health + 1);
 }