Ejemplo n.º 1
0
        public static bool CastQ(Obj_AI_Hero target, QMode qMode)
        {
            if (!LeeMethods.Q.IsReady() || LeeMethods.Q.Instance.Name != "BlindMonkQOne")
            {
                return(false);
            }
            var casted      = false;
            var qPrediction = LeeMethods.Q.GetPrediction(target);
            var useSmite    = LeeSinSharp.SmiteSlot != SpellSlot.Unknown &&
                              LeeMethods.Player.SummonerSpellbook.CanUseSpell(LeeSinSharp.SmiteSlot) == SpellState.Ready &&
                              (qPrediction.CollisionObjects.Count == 1 && qPrediction.Hitchance.Equals(HitChance.High) &&
                               ((qMode == QMode.Combo && MenuParamBool("smiteCombo")) ||
                                (qMode == QMode.Insec && MenuParamBool("smiteInsec")) ||
                                (qMode == QMode.Harass && MenuParamBool("smiteHarass"))));

            if (qPrediction.Hitchance == GetHitChance(Config.Menu.Item("qHitchance").GetValue <StringList>().SelectedIndex))
            {
            }

            if (useSmite)
            {
                LeeMethods.Player.SummonerSpellbook.CastSpell(LeeSinSharp.SmiteSlot, qPrediction.CollisionObjects[0]);
                if (LeeMethods.Q.CastIfHitchanceEquals(target, GetHitChance(Config.Menu.Item("qHitchance").GetValue <StringList>().SelectedIndex)))
                {
                    casted = true;
                }
            }
            else if (qPrediction.CollisionObjects.Count == 0)
            {
                if (LeeMethods.Q.CastIfHitchanceEquals(target, GetHitChance(Config.Menu.Item("qHitchance").GetValue <StringList>().SelectedIndex)))
                {
                    casted = true;
                }
            }

            return(casted);
        }
Ejemplo n.º 2
0
        // tạo dữ liệu cấu trúc lưu
        public static SaveData CreateSaveData(List <QGameObject> qGameObjects, Canvas cvMap, int width, int height, QMode mode)
        {
            SaveData data;

            //Vector tmpVector = Management.GetBoundOfMap(cvMap, ref width, ref height);
            //Management.TranslatePosition(cvMap, -(int)tmpVector.X, (int)tmpVector.Y);
            width = Management.GetHorBoundOfMap(cvMap);
            //height = Management.GetVerBoundOfMap(cvMap);

            int dimension;

            if (width > height)
            {
                dimension = width;
            }
            else
            {
                dimension = height;
            }
            if (dimension < 800)
            {
                dimension = 800;
            }

            QNode quadTree = new QNode(0, NodePosition.TOP_LEFT, new Rectangle(0, dimension, dimension * 2, dimension * 2));

            int  idCount = 0;
            bool isNonStatic;
            //List<QGameObject> qGameObjects = new List<QGameObject>();

            int total = 0;

            foreach (var item in cvMap.Children)
            {
                if (item is Image && ((Image)item).Opacity != 0.5f) // Không phải hình ảo
                {
                    total++;
                }
            }

            if (QNode.Mode == QMode.DRAW)
            {
                foreach (var item in cvMap.Children)
                {
                    if (item is Image && ((Image)item).Opacity != 0.5f) // Không phải hình ảo
                    {
                        Image i = item as Image;

                        if (Factory.CheckObjectType((EObjectName)i.Tag) == ObjectType.NON_STATIC)
                        {
                            isNonStatic = true;
                        }
                        else
                        {
                            isNonStatic = false;
                        }

                        if (Factory.CheckObjectCollisionAbility((EObjectName)i.Tag) == false)
                        {
                            // Add đối tượng vào Quadtree, đối với cây UPDATE chỉ add các đối tượng có thể va chạm
                            QGameObject o = new QGameObject(
                                idCount++,
                                (int)i.Tag,
                                new Rectangle((int)Canvas.GetLeft(i), height - (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                isNonStatic);
                            qGameObjects.Add(o);
                        }
                        else
                        {
                            QGameObject o = new QGameObject(
                                --total,
                                (int)i.Tag,
                                new Rectangle((int)Canvas.GetLeft(i), height - (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                isNonStatic);
                            qGameObjects.Add(o);
                        }

                        /*
                         * else
                         * {
                         * if (Factory.CheckObjectCollisionAbility((EObjectName)i.Tag))
                         * {
                         *  QGameObject o = new QGameObject(
                         *      idCount++,
                         *      (int)i.Tag,
                         *      new Rectangle((int)Canvas.GetLeft(i), height - (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                         *      isNonStatic);
                         *  qGameObjects.Add(o);
                         * }
                         * }*/
                    }
                }
            }
            else
            {
                for (int i = 0; i < qGameObjects.Count;)
                {
                    if (Factory.CheckObjectCollisionAbility((EObjectName)qGameObjects[i].Type) == false)
                    {
                        qGameObjects.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            for (int i = 0; i < qGameObjects.Count - 1; i++)
            {
                for (int j = i + 1; j < qGameObjects.Count; j++)
                {
                    if (qGameObjects[i].ID > qGameObjects[j].ID)
                    {
                        QGameObject tmp = qGameObjects[i];
                        qGameObjects[i] = qGameObjects[j];
                        qGameObjects[j] = tmp;
                    }
                }
            }

            foreach (var item in qGameObjects)
            {
                quadTree.Insert(item);
            }

            List <QNode> listQNodes = new List <QNode>();
            List <Node>  nodes      = new List <Node>();

            quadTree.GetNode(ref listQNodes);
            nodes = Factory.TransformFromQNodeToNode(listQNodes);

            data.Width  = width;
            data.Height = height;
            data.Nodes  = nodes.ToArray <Node>();

            return(data);
        }
Ejemplo n.º 3
0
        // tạo dữ liệu cấu trúc lưu
        public static SaveData CreateSaveData(List <QGameObject> qGameObjects, Canvas cvMap, int width, int height, QMode mode)
        {
            SaveData data;

            //Vector tmpVector = Management.GetBoundOfMap(cvMap, ref width, ref height);
            //Management.TranslatePosition(cvMap, -(int)tmpVector.X, (int)tmpVector.Y);
            //width = Management.GetHorBoundOfMap(cvMap);

            int dimension;

            if (width > height)
            {
                dimension = width;
            }
            else
            {
                dimension = height;
            }

            if (dimension < 368)
            {
                dimension = 368;
            }

            QNode quadTree = new QNode(0, NodePosition.TOP_LEFT, new Rectangle(0, 0, dimension * 2, dimension * 2));

            int  idCount = 0;
            bool isNonStatic;
            //List<QGameObject> qGameObjects = new List<QGameObject>();

            int total = 0;

            foreach (var item in cvMap.Children)
            {
                if (item is Image && ((Image)item).Opacity != 0.5f) // Không phải hình ảo
                {
                    total++;
                }
            }

            if (QNode.Mode == QMode.DRAW)
            {
                foreach (var item in cvMap.Children)
                {
                    if (item is Image && ((Image)item).Opacity != 0.5f) // Không phải hình ảo
                    {
                        Image i = item as Image;

                        //if (Factory.CheckObjectType((EObjectName)i.Tag) == ObjectType.NON_STATIC)
                        //{
                        //    isNonStatic = true;
                        //}
                        //else
                        //{
                        //    isNonStatic = false;
                        //}

                        //if (Factory.CheckObjectCollisionAbility((EObjectName)i.Tag) == false)
                        //{
                        // Add đối tượng vào Quadtree, đối với cây UPDATE chỉ add các đối tượng có thể va chạm
                        if ((EObjectName)i.Tag == EObjectName.BRICK_COIN || (EObjectName)i.Tag == EObjectName.BRICK_FLOWER || (EObjectName)i.Tag == EObjectName.BRICK_SUPPERMUSHROOM ||
                            (EObjectName)i.Tag == EObjectName.BRICK_1UPMUSHROOM || (EObjectName)i.Tag == EObjectName.BRICK_STAR || (EObjectName)i.Tag == EObjectName.BRICK_QUESTION_ITEM)
                        {
                            QGameObject o1 = new QGameObject(
                                idCount++,
                                (int)EObjectName.MISC_QUESTION_BRICK,
                                new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                false);
                            qGameObjects.Add(o1);
                            QGameObject o2 = null;
                            switch ((EObjectName)i.Tag)
                            {
                            case EObjectName.BRICK_COIN:
                                o2 = new QGameObject(
                                    idCount++,
                                    (int)EObjectName.ITEM_COIN_ACTIVATED,
                                    new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                    false);
                                qGameObjects.Add(o2);
                                break;

                            case EObjectName.BRICK_FLOWER:
                                o2 = new QGameObject(
                                    idCount++,
                                    (int)EObjectName.ITEM_FIRE_FLOWER,
                                    new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                    false);
                                qGameObjects.Add(o2);
                                break;

                            case EObjectName.BRICK_SUPPERMUSHROOM:
                                o2 = new QGameObject(
                                    idCount++,
                                    (int)EObjectName.ITEM_SUPER_MUSHROOM,
                                    new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                    false);
                                qGameObjects.Add(o2);
                                break;

                            case EObjectName.BRICK_1UPMUSHROOM:
                                o2 = new QGameObject(
                                    idCount++,
                                    (int)EObjectName.ITEM_1UP_MUSHROOM,
                                    new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                    false);
                                qGameObjects.Add(o2);
                                break;

                            case EObjectName.BRICK_STAR:
                                o2 = new QGameObject(
                                    idCount++,
                                    (int)EObjectName.ITEM_STARMAN,
                                    new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                    false);
                                qGameObjects.Add(o2);
                                break;

                            case EObjectName.BRICK_QUESTION_ITEM:
                                o2 = new QGameObject(
                                    idCount++,
                                    (int)EObjectName.ITEM_GROW_UP,
                                    new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                    false);
                                qGameObjects.Add(o2);
                                break;

                            default:
                                break;
                            }
                        }
                        else if ((EObjectName)i.Tag == EObjectName.ENEMY_GOOMBA_OW || (EObjectName)i.Tag == EObjectName.ENEMY_KOOPA_OW || (EObjectName)i.Tag == EObjectName.ENEMY_BOSS)
                        {
                            QGameObject o1 = new QGameObject(
                                idCount++,
                                (int)i.Tag,
                                new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                false);
                            qGameObjects.Add(o1);
                        }
                        else
                        {
                            QGameObject o = new QGameObject(
                                idCount++,
                                (int)i.Tag,
                                //new Rectangle((int)Canvas.GetLeft(i), height - (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                                false);
                            qGameObjects.Add(o);
                        }
                    }
                    //else
                    //{
                    //    QGameObject o = new QGameObject(
                    //        --total,
                    //        (int)i.Tag,
                    //        //new Rectangle((int)Canvas.GetLeft(i), height - (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                    //        new Rectangle((int)Canvas.GetLeft(i), (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                    //        isNonStatic);
                    //    qGameObjects.Add(o);
                    //}

                    /*
                     * else
                     * {
                     * if (Factory.CheckObjectCollisionAbility((EObjectName)i.Tag))
                     * {
                     *  QGameObject o = new QGameObject(
                     *      idCount++,
                     *      (int)i.Tag,
                     *      new Rectangle((int)Canvas.GetLeft(i), height - (int)Canvas.GetTop(i), (int)i.Width, (int)i.Height),
                     *      isNonStatic);
                     *  qGameObjects.Add(o);
                     * }
                     * }*/
                    //}
                }
            }
            else
            {
                for (int i = 0; i < qGameObjects.Count;)
                {
                    if (Factory.CheckObjectCollisionAbility((EObjectName)qGameObjects[i].Type) == false)
                    {
                        qGameObjects.RemoveAt(i);
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            for (int i = 0; i < qGameObjects.Count - 1; i++)
            {
                for (int j = i + 1; j < qGameObjects.Count; j++)
                {
                    if (qGameObjects[i].ID > qGameObjects[j].ID)
                    {
                        QGameObject tmp = qGameObjects[i];
                        qGameObjects[i] = qGameObjects[j];
                        qGameObjects[j] = tmp;
                    }
                }
            }

            foreach (var item in qGameObjects)
            {
                quadTree.Insert(item);
            }

            List <QNode> listQNodes = new List <QNode>();
            List <Node>  nodes      = new List <Node>();

            quadTree.GetNode(ref listQNodes);
            nodes = Factory.TransformFromQNodeToNode(listQNodes);

            data.Width  = width;
            data.Height = height;
            data.Nodes  = nodes.ToArray <Node>();

            return(data);
        }