コード例 #1
0
 public void CalcCount(ref int generalCount, ref int specialCount, ref int deleteCount)
 {
     generalCount = 0;
     specialCount = 0;
     deleteCount  = 0;
     BrickInst[] array = BrickManager.Instance.ToBrickInstArray();
     for (int i = 0; i < array.Length; i++)
     {
         Brick brick = BrickManager.Instance.GetBrick(array[i].Template);
         if (brick != null && !dicRegMap.ContainsKey(array[i].Seq))
         {
             if (brick.category == Brick.CATEGORY.ACCESSORY || brick.category == Brick.CATEGORY.FUNCTIONAL)
             {
                 specialCount++;
             }
             else
             {
                 generalCount++;
             }
         }
     }
     foreach (KeyValuePair <int, int> item in dicRegMap)
     {
         BrickInst brickInst = BrickManager.Instance.GetBrickInst(item.Key);
         if (brickInst == null)
         {
             deleteCount++;
         }
     }
 }
コード例 #2
0
    public void MoveNext(bool success)
    {
        if (success)
        {
            doneCount++;
        }
        BrickInst brickInst = null;

        if (CheckCount(next) && UserMapInfoManager.Instance.CheckAuth(showMessage: true))
        {
            while (brickInst == null && todo.Count > 0)
            {
                brickInst = todo.Peek();
                BrickInst brickInst2 = BrickManager.Instance.GetBrickInst(brickInst.Seq);
                if (brickInst2 == null)
                {
                    brickInst = null;
                }
                todo.Dequeue();
            }
        }
        if (brickInst == null)
        {
            progressing = false;
        }
        else
        {
            CSNetManager.Instance.Sock.SendCS_REPLACE_BRICK_REQ(item.Seq, item.Template.code, brickInst.Seq, next.index, brickInst.PosX, brickInst.PosY, brickInst.PosZ, brickInst.Rot);
        }
    }
コード例 #3
0
    private bool CheckAlias()
    {
        bool flag = false;

        BrickProperty[] allScriptables = BrickManager.Instance.GetAllScriptables();
        if (allScriptables != null)
        {
            int num = 0;
            while (!flag && num < allScriptables.Length)
            {
                if (allScriptables[num].Seq != prop.Seq)
                {
                    BrickInst brickInst = BrickManager.Instance.GetBrickInst(allScriptables[num].Seq);
                    if (brickInst != null && brickInst.BrickForceScript.Alias == alias)
                    {
                        flag = true;
                    }
                }
                num++;
            }
        }
        if (flag)
        {
            MessageBoxMgr.Instance.AddMessage(StringMgr.Instance.Get("DUPLICATED_SCRIPT_ALIAS"));
        }
        return(!flag);
    }
コード例 #4
0
 public void InitDialog(BrickProperty _prop, Brick _brick, BrickInst _inst)
 {
     prop           = _prop;
     brick          = _brick;
     selected       = 0;
     scrollPosition = Vector2.zero;
     spId           = Vector2.zero;
     if (_inst.BrickForceScript != null)
     {
         alias          = _inst.BrickForceScript.Alias;
         enableOnAwake  = _inst.BrickForceScript.EnableOnAwake;
         visibleOnAwake = _inst.BrickForceScript.VisibleOnAwake;
         cmdList.Clear();
         for (int i = 0; i < _inst.BrickForceScript.CmdList.Count; i++)
         {
             cmdList.Add(_inst.BrickForceScript.CmdList[i]);
         }
     }
 }
コード例 #5
0
    private void MoveFirst()
    {
        BrickInst brickInst = null;

        if (CheckCount(next) && UserMapInfoManager.Instance.CheckAuth(showMessage: true) && BrickManager.Instance.checkAddMinMaxGravity(next.seq))
        {
            while (brickInst == null && todo.Count > 0)
            {
                brickInst = todo.Peek();
                BrickInst brickInst2 = BrickManager.Instance.GetBrickInst(brickInst.Seq);
                if (brickInst2 == null)
                {
                    brickInst = null;
                }
                todo.Dequeue();
            }
        }
        if (brickInst != null)
        {
            progressing = true;
            CSNetManager.Instance.Sock.SendCS_REPLACE_BRICK_REQ(item.Seq, item.Template.code, brickInst.Seq, next.index, brickInst.PosX, brickInst.PosY, brickInst.PosZ, brickInst.Rot);
        }
    }
コード例 #6
0
 private void ShowTarget(bool show)
 {
     if (!(null == target))
     {
         if (show)
         {
             BrickInst hitBrickInst = BrickManager.Instance.GetHitBrickInst(hitBrick.transform.gameObject, hitBrick.normal, hitBrick.point);
             if (hitBrickInst == null)
             {
                 show = false;
             }
             else
             {
                 Vector3     vector           = new Vector3((float)(int)hitBrickInst.PosX, (float)(int)hitBrickInst.PosY, (float)(int)hitBrickInst.PosZ);
                 GameObject  brickObjectByPos = BrickManager.Instance.GetBrickObjectByPos(vector);
                 BoxCollider boxCollider      = null;
                 if (brickObjectByPos != null)
                 {
                     boxCollider = brickObjectByPos.GetComponent <BoxCollider>();
                 }
                 if (null != boxCollider)
                 {
                     target.GetComponent <ComposerTarget>().CenterAndSize(boxCollider.center, boxCollider.size);
                     target.transform.position = vector;
                     target.transform.rotation = Rot.ToQuaternion(hitBrickInst.Rot);
                 }
                 else
                 {
                     target.GetComponent <ComposerTarget>().CenterAndSize(new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f));
                     target.transform.position = vector;
                     target.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
                 }
             }
         }
         target.GetComponent <ComposerTarget>().ShowTarget(show);
     }
 }
コード例 #7
0
    private void Start()
    {
        script = null;
        BrickProperty component = base.transform.parent.gameObject.GetComponent <BrickProperty>();

        if (null == component)
        {
            Debug.LogError("Fail to find BrickProperty");
        }
        else
        {
            BrickInst brickInst = BrickManager.Instance.GetBrickInst(component.Seq);
            if (brickInst == null)
            {
                Debug.LogError("Fail to find BrickInst ");
            }
            else
            {
                script = brickInst.BrickForceScript;
            }
            base.enabled = script.EnableOnAwake;
            Show(script.VisibleOnAwake);
        }
    }
コード例 #8
0
 private void DoEnableScript(EnableScript enableScript)
 {
     BrickProperty[] allScriptables = BrickManager.Instance.GetAllScriptables();
     if (allScriptables != null)
     {
         int            num  = -1;
         List <Texture> list = new List <Texture>();
         for (int i = 0; i < allScriptables.Length; i++)
         {
             Brick brick = BrickManager.Instance.GetBrick(allScriptables[i].Index);
             if (brick != null)
             {
                 list.Add(brick.Icon);
             }
             else
             {
                 Debug.LogError("Fail to get scriptables icon ");
             }
             if (enableScript.Id == allScriptables[i].Seq)
             {
                 num = i;
             }
         }
         if (num < 0)
         {
             num = 0;
         }
         Texture[] array    = list.ToArray();
         int       num2     = array.Length;
         Rect      rect     = new Rect(0f, 0f, 48f, (float)(num2 * 48));
         Rect      position = new Rect(size.x / 2f + 4f, 112f, size.x / 2f - 8f, 192f);
         spId            = GUI.BeginScrollView(position, spId, rect);
         num             = GUI.SelectionGrid(rect, num, array, 1);
         enableScript.Id = allScriptables[num].Seq;
         Color   color  = GUI.color;
         Vector2 vector = new Vector2(52f, 0f);
         for (int j = 0; j < allScriptables.Length; j++)
         {
             if (j == num)
             {
                 GUI.color = new Color(0.83f, 0.49f, 0.29f);
             }
             else
             {
                 GUI.color = Color.white;
             }
             BrickInst brickInst = BrickManager.Instance.GetBrickInst(allScriptables[j].Seq);
             if (brickInst == null || brickInst.BrickForceScript == null || brickInst.BrickForceScript.Alias.Length <= 0)
             {
                 GUI.Label(new Rect(vector.x, vector.y, size.x / 2f - 60f, 48f), allScriptables[j].Seq.ToString(), "MiniLabel");
             }
             else
             {
                 string text = (allScriptables[j].Seq != prop.Seq) ? brickInst.BrickForceScript.Alias : alias;
                 GUI.Label(new Rect(vector.x, vector.y, size.x / 2f - 60f, 48f), text, "MiniLabel");
             }
             vector.y += 48f;
         }
         GUI.color = color;
         GUI.EndScrollView();
     }
     enableScript.Enable = GUI.Toggle(new Rect(size.x / 2f + 4f, 310f, 128f, 13f), enableScript.Enable, StringMgr.Instance.Get("ENABLE_OR"));
 }
コード例 #9
0
ファイル: MonAI.cs プロジェクト: AnonVodka/Brick-Force-Aurora
    public void EraseWay(Vector3 cen)
    {
        Vector3   pos   = cen;
        BrickInst byPos = BrickManager.Instance.GetByPos(pos);

        if (byPos == null)
        {
            Debug.LogError("bi == null");
        }
        int num = -1;

        pos.x -= 3f;
        byPos  = BrickManager.Instance.GetByPos(pos);
        if (byPos != null)
        {
            num = traceCreatedID(byPos.Seq);
        }
        pos    = cen;
        pos.x += 3f;
        byPos  = BrickManager.Instance.GetByPos(pos);
        if (byPos != null && (num == -1 || num > traceCreatedID(byPos.Seq)))
        {
            num = traceCreatedID(byPos.Seq);
        }
        pos    = cen;
        pos.z -= 3f;
        byPos  = BrickManager.Instance.GetByPos(pos);
        if (byPos != null && (num == -1 || num > traceCreatedID(byPos.Seq)))
        {
            num = traceCreatedID(byPos.Seq);
        }
        pos    = cen;
        pos.z += 3f;
        byPos  = BrickManager.Instance.GetByPos(pos);
        if (byPos != null && (num == -1 || num > traceCreatedID(byPos.Seq)))
        {
            num = traceCreatedID(byPos.Seq);
        }
        pos    = cen;
        pos.y -= 3f;
        byPos  = BrickManager.Instance.GetByPos(pos);
        if (byPos != null && (num == -1 || num > traceCreatedID(byPos.Seq)))
        {
            num = traceCreatedID(byPos.Seq);
        }
        pos    = cen;
        pos.y += 3f;
        byPos  = BrickManager.Instance.GetByPos(pos);
        if (byPos != null && (num == -1 || num > traceCreatedID(byPos.Seq)))
        {
            num = traceCreatedID(byPos.Seq);
        }
        if (num == -1)
        {
            Debug.LogError("(EraseWay)Perfect Error");
        }
        else
        {
            EraseTrace(num);
        }
    }
コード例 #10
0
ファイル: MonAI.cs プロジェクト: AnonVodka/Brick-Force-Aurora
    public bool FindWay(Vector3 cen)
    {
        cen.y -= flyHeight;
        Vector3   vector = cen;
        BrickInst byPos  = BrickManager.Instance.GetByPos(vector);

        if (byPos == null)
        {
            Debug.LogError("bi == null");
        }
        Vector3        item  = cen;
        List <Vector3> list  = new List <Vector3>();
        List <int>     list2 = new List <int>();

        vector.x -= 3f;
        byPos     = BrickManager.Instance.GetByPos(vector);
        if (byPos != null && !CheckTraces(byPos.Seq, byPos.Template))
        {
            item    = vector;
            item.y += flyHeight;
            list.Add(item);
            list2.Add(byPos.Seq);
        }
        vector    = cen;
        vector.x += 3f;
        byPos     = BrickManager.Instance.GetByPos(vector);
        if (byPos != null && !CheckTraces(byPos.Seq, byPos.Template))
        {
            item    = vector;
            item.y += flyHeight;
            list.Add(item);
            list2.Add(byPos.Seq);
        }
        vector    = cen;
        vector.z -= 3f;
        byPos     = BrickManager.Instance.GetByPos(vector);
        if (byPos != null && !CheckTraces(byPos.Seq, byPos.Template))
        {
            item    = vector;
            item.y += flyHeight;
            list.Add(item);
            list2.Add(byPos.Seq);
        }
        vector    = cen;
        vector.z += 3f;
        byPos     = BrickManager.Instance.GetByPos(vector);
        if (byPos != null && !CheckTraces(byPos.Seq, byPos.Template))
        {
            item    = vector;
            item.y += flyHeight;
            list.Add(item);
            list2.Add(byPos.Seq);
        }
        vector    = cen;
        vector.y -= 3f;
        byPos     = BrickManager.Instance.GetByPos(vector);
        if (byPos != null && !CheckTraces(byPos.Seq, byPos.Template))
        {
            item    = vector;
            item.y += flyHeight;
            list.Add(item);
            list2.Add(byPos.Seq);
        }
        vector    = cen;
        vector.y += 3f;
        byPos     = BrickManager.Instance.GetByPos(vector);
        if (byPos != null && !CheckTraces(byPos.Seq, byPos.Template))
        {
            item    = vector;
            item.y += flyHeight;
            list.Add(item);
            list2.Add(byPos.Seq);
        }
        if (list.Count == 0)
        {
            EraseWay(cen);
            return(false);
        }
        if (list.Count == 1)
        {
            if (readyP2P == 0)
            {
                readyP2P = 1;
            }
            vTarget = list[0];
            traces.Add(new CTrace(created++, list2[0]));
        }
        else
        {
            List <int> list3       = new List <int>();
            Vector3    vDefenseEnd = GlobalVars.Instance.vDefenseEnd;
            int        num         = 65535;
            int        num2        = -1;
            for (int i = 0; i < list.Count; i++)
            {
                int num3 = (int)Vector3.Distance(vDefenseEnd, list[i]);
                if (num > num3)
                {
                    num  = num3;
                    num2 = i;
                }
            }
            list3.Add(num2);
            for (int j = 0; j < list.Count; j++)
            {
                if (j != num2)
                {
                    int num4 = (int)Vector3.Distance(vDefenseEnd, list[j]);
                    if (num == num4)
                    {
                        list3.Add(j);
                    }
                }
            }
            if (list3.Count == 1)
            {
                if (readyP2P == 0)
                {
                    readyP2P = 1;
                }
                vTarget = list[list3[0]];
                traces.Add(new CTrace(created++, list2[list3[0]]));
            }
            else
            {
                int index = Random.Range(0, list3.Count);
                vTarget = list[index];
                traces.Add(new CTrace(created++, list2[index]));
                if (readyP2P == 0)
                {
                    readyP2P = 1;
                }
            }
        }
        if (Mathf.Abs(vTarget.y - vCur.y) > 1f)
        {
            IsUpDown = true;
        }
        return(true);
    }