Beispiel #1
0
 public override void Attack()
 {
     if (boss != null && blood > 0)
     {
         if (target != null)
         {
             float juli = Vector3.Distance(transform.position, target.transform.position);
             if (juli < maxAttackDistance + spanDistance)
             {
                 BatteryParent batteryScript = target.GetComponent <BatteryParent>();
                 if (batteryScript != null && batteryScript.blood > 0)
                 {
                     animator.SetInteger("attackType", random.Next(1, 3));
                     animator.SetBool("canAttack", true);
                     batteryScript.blood -= attackValue;
                     batteryScript.BeAttack();
                     if (batteryScript.blood <= 0)
                     {
                         HandleDieTarget(target);
                     }
                 }
                 else
                 {
                     HandleDieTarget(target);
                 }
             }
             else
             {
                 target = null;
             }
         }
     }
 }
Beispiel #2
0
    public virtual GameObject InstanceManagerBatteryObj(BatteryConfigInfo info, Transform parent, int level = 1)
    {
        Object obj = Resources.Load(info.battleType + "Lv" + level);

        if (obj != null)
        {
            GameObject tempGO = Instantiate(obj) as GameObject;
            tempGO.transform.parent = parent;
            //tempGO.transform.localScale = Vector3.one;
            tempGO.transform.localPosition = Vector3.zero;
            BatteryParent bp = tempGO.GetComponent <BatteryParent>();
            bp.batteryName          = info.batteryName;
            bp.attackValue          = info.attackValue;
            bp.attackRepeatRateTime = info.attackRepeatRateTime;
            bp.blood             = info.blood;
            bp.desc              = info.desc;
            bp.icon              = info.icon;
            bp.maxAttackDistance = info.maxAttackDistance;
            bp.model             = info.model;
            bp.MW         = info.MW;
            bp.battleType = info.battleType;
            bp.starLevel  = info.starLevel;
            bp.wood       = info.wood;

            Vector3 vv = Vector3.zero;
            vv.y = tempGO.transform.position.y;
            tempGO.transform.LookAt(vv);
            tempGO.transform.Rotate(Vector3.up, 180);

            return(tempGO);
        }
        return(null);
    }
Beispiel #3
0
 void SetBatteryState(Transform battery, bool show)
 {
     if (battery)
     {
         BatteryParent bp = battery.GetComponent <BatteryParent>();
         if (bp != null)
         {
             if (!show)
             {
                 battery.localScale = Vector3.zero;
                 //Scene currentScene = SceneManager.GetActiveScene();
                 //if (currentScene.name.Equals("Fight"))
                 //{
                 //    Animator anima = battery.GetComponent<Animator>();
                 //    if (anima != null)
                 //    {
                 //        AnimatorStateInfo animatorStateInfo = anima.GetCurrentAnimatorStateInfo(0);
                 //        if (!animatorStateInfo.IsName("Base Layer.houseBX"))
                 //        {
                 //            anima.SetTrigger("houseBX");
                 //        }
                 //    }
                 //}
                 bp.enabled = false;
             }
             else
             {
                 battery.localScale = Vector3.one;
                 //Scene currentScene = SceneManager.GetActiveScene();
                 //if (currentScene.name.Equals("Fight"))
                 //{
                 //    Animator anima = battery.GetComponent<Animator>();
                 //    if (anima != null)
                 //    {
                 //        AnimatorStateInfo animatorStateInfo = anima.GetCurrentAnimatorStateInfo(0);
                 //        if (!animatorStateInfo.IsName("Base Layer.batteryBX"))
                 //        {
                 //            anima.SetTrigger("batteryBX");
                 //        }
                 //    }
                 //}
                 bp.enabled = true;
             }
         }
     }
 }
Beispiel #4
0
    public void getTarget()
    {
        if (target == null && blood > 0)
        {
            if (attackTargetList.Count > 0)
            {
                GameObject nearBattery = attackTargetList[attackTargetList.Count - 1];
                if (nearBattery != null)
                {
                    float tempDistance = Vector3.Distance(transform.position, nearBattery.transform.position);
                    for (int i = attackTargetList.Count - 2; i >= 0; i--)
                    {
                        GameObject tempBattery = attackTargetList[i];
                        if (tempBattery != null)
                        {
                            float distance = Vector3.Distance(transform.position, tempBattery.transform.position);

                            if (distance < tempDistance)
                            {
                                tempDistance = distance;
                                nearBattery  = tempBattery;
                            }
                        }
                    }

                    float juli = Vector3.Distance(transform.position, nearBattery.transform.position);
                    if (juli < maxAttackDistance + spanDistance)
                    {
                        BatteryParent bp = nearBattery.GetComponent <BatteryParent>();
                        if (bp != null && bp.blood > 0)
                        {
                            target = nearBattery;
                            return;
                        }
                        else
                        {
                            attackTargetList.Remove(nearBattery);
                        }
                    }
                }
            }
        }
    }
Beispiel #5
0
    public void buildOVerPlaceBattery()
    {
        if (tempInfo != null && tempHole != null)
        {
            currentBatteryObj = recoverBatteryDataBase.SpawnBattery(tempInfo, tempHole);
            //currentBatteryObj = tempHole.GetChild(2).gameObject;

            BatteryParent bp = currentBatteryObj.GetComponent <BatteryParent>();
            if (bp != null)
            {
                bp.ShowBuildOverCanvas();
            }
            ChangeHighLight();
        }
        if (tempBuildOverTarget != null)
        {
            Destroy(tempBuildOverTarget);
        }
    }
Beispiel #6
0
    void HandleDieTarget(GameObject temp)
    {
        BatteryParent bp = temp.GetComponent <BatteryParent>();

        if (bp != null)
        {
            List <GameObject> bList = bp.holeListForGroupBattery;
            if (bList != null && bList.Count > 0)
            {
                for (int j = 0; j < bList.Count; j++)
                {
                    recoverBatteryDataBase.DestoryBattery(bList[j].transform);
                }
            }
            recoverBatteryDataBase.DestoryGroupBattery(temp);
        }
        attackTargetList.Remove(temp);
        SpawnPoHuai(temp.transform.parent);
        target = null;
    }
Beispiel #7
0
    public GameObject SpawnSingleRange(ServerBatteryData bd, Transform parent)
    {
        GameObject go = null;

        //if (holeDic.ContainsKey(bd.index))
        {
            if (BatteryDataConfigTable.dic.ContainsKey(bd.batteryType))
            {
                Object obj = null;
                if (BatteryDataConfigTable.dic[bd.batteryType].maxAttackDistance == 45)
                {
                    obj = Resources.Load("range1");
                }
                else if (BatteryDataConfigTable.dic[bd.batteryType].maxAttackDistance == 65)
                {
                    obj = Resources.Load("range2");
                }
                else if (BatteryDataConfigTable.dic[bd.batteryType].maxAttackDistance == 80)
                {
                    obj = Resources.Load("range3");
                }
                if (obj != null)
                {
                    go = (GameObject)Instantiate(obj);
                    go.transform.parent     = parent;
                    go.transform.localScale = Vector3.one;

                    float angle = 0;
                    if (bd.index > 0 && bd.index < 9)
                    {
                        angle = 25 + 45 * (bd.index - 1);
                    }
                    else if (bd.index >= 9 && bd.index < 25)
                    {
                        int tIndex = bd.index - 8;
                        angle = 25 + 22.5f * (tIndex - 1);
                    }
                    else if (bd.index >= 25 && bd.index < 49)
                    {
                        int tIndex = bd.index - 24;
                        angle = -65 + 15 * (tIndex - 1);
                    }
                    else
                    {
                        int tIndex = bd.index - 48;
                        angle = 25 + 11.25f * (tIndex - 1);
                    }
                    go.transform.Rotate(0, 0, angle);

                    Range rangeScript = go.GetComponent <Range>();
                    if (rangeScript != null)
                    {
                        List <Range> list = RangeCheckManager.rangeList;
                        if (!list.Contains(rangeScript))
                        {
                            list.Add(rangeScript);
                        }
                    }
                    BatteryParent bp = go.transform.parent.GetComponent <BatteryParent>();
                    go.transform.GetChild(go.transform.childCount - 1).GetComponent <ConfirmEnemy>().bp = bp;
                }
            }
        }
        return(go);
    }