Esempio n. 1
0
    public void DestoryBattery(Transform hold)
    {
        if (hold != null)
        {
            BuildConfig tBuildConfig = hold.GetComponent <BuildConfig>();
            if (tBuildConfig != null && hasHoleWithTypeDic.ContainsKey(tBuildConfig.index))
            {
                hasHoleWithTypeDic.Remove(tBuildConfig.index);

                GameObject tBattleTarget = hold.GetChild(2).gameObject;
                GameObject tRangeTarget  = tBattleTarget.transform.GetChild(tBattleTarget.transform.childCount - 1).gameObject;
                if (tRangeTarget != null)
                {
                    Range range = tRangeTarget.GetComponent <Range>();
                    if (range != null && RangeCheckManager.rangeList.Contains(range))
                    {
                        RangeCheckManager.rangeList.Remove(range);
                    }
                    DestroyImmediate(tRangeTarget);
                }
                DestroyImmediate(tBattleTarget);

                ServerBatteryData bd = new ServerBatteryData();
                bd.batteryLevel = 1;
                bd.index        = tBuildConfig.index;
                ServerDataHelper.DeleteSingleServerBatteryData(bd);

                CheckGroup();
                CheckRange();
            }
        }
    }
Esempio n. 2
0
    public static void AddSingleServerBatteryData(ServerBatteryData bt)
    {
        int count = batteryDataList.FindAll(item => { return(item.index == bt.index); }).Count;

        if (count <= 0)
        {
            batteryDataList.Add(bt);
        }
    }
Esempio n. 3
0
 public static void DeleteSingleServerBatteryData(ServerBatteryData bt)
 {
     if (batteryDataList != null && batteryDataList.Count > 0)
     {
         for (int i = 0; i < batteryDataList.Count; i++)
         {
             if (batteryDataList[i].index == bt.index)
             {
                 batteryDataList.Remove(batteryDataList[i]);
                 return;
             }
         }
     }
 }
Esempio n. 4
0
    public virtual GameObject SpawnBattery(BatteryConfigInfo info, Transform hole, int level = 1)
    {
        GameObject go = null;

        if (hole != null && info != null)
        {
            go = InstanceManagerBatteryObj(info, hole, level);
            if (go != null)
            {
                int index = hole.GetComponent <BuildConfig>().index;

                ServerBatteryData bd = new ServerBatteryData();
                bd.batteryLevel = level;
                bd.batteryType  = info.battleType;
                bd.index        = index;

                if (level == 1)
                {
                    hasHoleWithTypeDic[index] = info.battleType;
                    ServerDataHelper.AddSingleServerBatteryData(bd);

                    SpawnSingleRange(bd, go.transform);
                    CheckGroup();
                    CheckRange();
                }
                else
                {
                    if (level == 2)
                    {
                        go.transform.Translate(go.transform.forward * 3, Space.World);
                    }

                    SpawnSingleRange(bd, go.transform);
                    CheckRange();
                }
            }
        }
        return(go);
    }
Esempio n. 5
0
    public virtual void HandleRecoverData()
    {
        List <ServerBatteryData> serverDataList = ServerDataHelper.GetServerBatteryData();

        if (batteryHoleList != null && batteryHoleList.Count > 0)
        {
            if (serverDataList != null && serverDataList.Count > 0)
            {
                for (int i = 0; i < serverDataList.Count; i++)
                {
                    ServerBatteryData bd = serverDataList[i];
                    if (holeDic.ContainsKey(bd.index))
                    {
                        if (BatteryDataConfigTable.dic.ContainsKey(bd.batteryType))
                        {
                            BatteryConfigInfo info = BatteryDataConfigTable.dic[bd.batteryType];
                            GameObject        hole = holeDic[bd.index];
                            SpawnBattery(info, hole.transform);
                        }
                    }
                }
            }
        }
    }
Esempio n. 6
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);
    }