Beispiel #1
0
        [OutputCache(Duration = 86400, VaryByParam = "*")] //缓存24个小时
        public void AreaDataToJson()
        {
            List <AreaInfo> list = GetArea.Do(0).Body.area_list;

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("var areas=[");
            int i = 0;

            foreach (AreaInfo s in list)
            {
                if (i > 0)
                {
                    sb.Append(",");
                }
                i++;
                sb.Append("{");
                sb.Append("'ID':" + s.area_id);
                sb.Append(",'ParentID':" + s.parent_id);
                sb.Append(",'AreaID':" + s.area_id);
                sb.Append(",'Code':'" + s.area_path + "'");
                sb.Append(",'Name':'" + s.area_name + "'");
                sb.Append("}");
            }
            sb.Append("];");
            System.Web.HttpContext.Current.Response.Write(sb.ToString());
            System.Web.HttpContext.Current.Response.End();
            //return Json(sList, JsonRequestBehavior.AllowGet);
        }
Beispiel #2
0
        public ActionResult PostShopData()
        {
            int      shopid = DoRequest.GetFormInt("shopid");
            ShopInfo shop   = GetShopDetail.Do(shopid).Body;

            shop.shop_name    = DoRequest.GetFormString("shopName");
            shop.company_name = DoRequest.GetFormString("Company");
            shop.shop_key     = DoRequest.GetFormString("keyword");
            shop.shop_pswd    = DoRequest.GetFormString("psword");

            int province = DoRequest.GetFormInt("province");
            int city     = DoRequest.GetFormInt("city");

            shop.area_id   = province;
            shop.shop_addr = GetArea.Do(province).Body.area_list[0].area_name;
            string cityName = GetArea.Do(city).Body.area_list[0].area_name;

            if (!cityName.StartsWith("市辖") && !cityName.StartsWith("直辖"))
            {
                shop.shop_addr += cityName;
            }
            shop.link_way    = DoRequest.GetFormString("linkway");
            shop.shop_remark = DoRequest.GetFormString("remarks");

            #region Checking
            if (shop.shop_name.Length < 1)
            {
                return(Json(new { error = true, message = "[名称] 不能为空" }));
            }
            if (shop.shop_name.Length > 50)
            {
                return(Json(new { error = true, message = "[名称] 不能大于50个字符" }));
            }
            if (shop.company_name.Length < 0 && shop.company_name.Length > 100)
            {
                return(Json(new { error = true, message = "[公司] 不能为空或大于100个字符" }));
            }
            if (shop.area_id < 0)
            {
                return(Json(new { error = true, message = "[发货地址] 不能为空" }));
            }
            #endregion

            int returnValue = -1;

            returnValue = int.Parse(OpShopInfo.Do(shop).Header.Result.Code);

            if (returnValue == 0)
            {
                return(Json(new { error = false, message = "操作成功" }));
            }
            return(Json(new { error = true, message = "操作失败" }));
        }
Beispiel #3
0
    /*
     * ApplyTileTint
     * private void function
     *
     * this starts off the adding of tiles to the texture image
     *
     * @returns nothing
     */
    private void ApplyTileTint()
    {
        //first set values to default
        List <Tiles> holder2 = new List <Tiles>();

        m_notInSightTiles.Clear();
        m_sightTiles.Clear();

        //go through and gather all tiles the player can "see"
        for (int i = 0; i < m_activeplayer.units.Count; i++)
        {
            if (m_activeplayer.units[i] != null)
            {
                holder2 = GetArea.GetAreaOfAttack(map.GetTileAtPos(m_activeplayer.units[i].transform.position), (int)m_activeplayer.units[i].AOV, map);
                for (int u = 0; u < holder2.Count; u++)
                {
                    if (CheckInSightTiles(holder2[u].indexPos) == false)
                    {
                        m_sightTiles.Add(holder2[u]);
                    }
                }
            }
        }

        //set not in sight tiles to be equal to all tiles
        List <Tiles> holder = map.mapTiles;

        //in all the not in sight tiles
        for (int i = 0; i < holder.Count; i++)
        {
            m_notInSightTiles.Add(holder[i]);
        }

        //go through and remove all of the sight tiles from the not in sight tiles
        for (int i = 0; i < m_sightTiles.Count; i++)
        {
            m_notInSightTiles.Remove(m_sightTiles[i]);
        }

        //function to apply the tiles to the texture
        MakeMapTextureOfTiles();
    }
Beispiel #4
0
    /*
     * ExecuteMovementGivenTarget
     *
     * given a target to move towards, find the
     * closest tile and move that way
     *
     * @param Unit unit - the unit that is undergoing the movement
     * @param Vector3 target - the vector to optimistically move towards
     * @returns void
     */
    public void ExecuteMovementGivenTarget(Unit unit, Vector3 target)
    {
        //get a list of walkable tiles around the unit
        List <Tiles> walkable = GetArea.GetAreaOfSafeMoveable(map.GetTileAtPos(unit.transform.position), unit.movementPoints, map, unit);

        //worst possible score to start
        float bestMoveScore = float.MaxValue;

        //reference to the best tile that has been found
        Tiles bestTargetTile = null;

        //get the size of the walkable list
        int walkSize = walkable.Count;

        //iterate through all walkable tiles
        for (int i = 0; i < walkSize; i++)
        {
            //store in a temp variable
            Tiles tile = walkable[i];

            //get the squared distance to the tile
            float sqrDistance = (tile.transform.position - target).sqrMagnitude;

            if (sqrDistance < bestMoveScore && tile.unit == null)
            {
                //bestTargetTile the best score
                bestTargetTile = tile;
                bestMoveScore  = sqrDistance;
            }
        }

        //move towards the best tile if one was found
        if (bestTargetTile != null)
        {
            Move(unit, bestTargetTile.pos);
        }
    }
Beispiel #5
0
 public override double Area()
 {
     GetArea?.Invoke();
     return(Math.Round(Height() * Width(), 2));
 }
Beispiel #6
0
    /*
     * Update
     * overrides UnitCommand's Update()
     *
     * called once per frame while the command is active
     *
     * @returns void
     */
    public override void Update()
    {
        unit.hasAttacked    = true;
        unit.movementPoints = 0;

        //count-down the attack timer
        attackTimer -= Time.deltaTime;

        if (attackTimer < 0.0f)
        {
            attackTimer = 0.0f;
        }
        else
        {
            return;
        }

        //only apply the direction once
        if (!applied)
        {
            int maxDistance = Mathf.CeilToInt(attackRadius);

            //get the surrounding tiles, not considering obstacles
            List <Tiles> area = GetArea.GetAreaOfAttack(endTile, maxDistance, map);

            //get the size of the area tiles list
            int areaSize = area.Count;

            //track the amount of enemies hit
            int enemiesHit = 0;

            //iterate through all of the tiles in the area, applying damage to all
            for (int i = 0; i < areaSize; i++)
            {
                Unit defendingUnit = area[i].unit;

                //if the defending unit exists and isn't a friendly unit
                if (defendingUnit != null && defendingUnit.playerID != unit.playerID)
                {
                    //relative vector from the start to the end
                    Vector3 relative = area[i].pos - endTile.pos;

                    //manhattan distance
                    int manhattDistance = (int)(relative.x + relative.z);

                    //damage fall-off
                    float ratio = 1 - ((float)(manhattDistance) / (float)(maxDistance + 1.0f));

                    unit.Attack(defendingUnit, ratio);

                    enemiesHit++;
                }
            }
            if (unit.ArtLink != null)
            {
                unit.ArtLink.SetBool("ActionsAvailable", false);
            }

            //reset the explosion
            ParticleLibrary.explosionSystem.transform.position = endTile.transform.position;
            ParticleLibrary.explosionSystem.time = 0.0f;
            ParticleLibrary.explosionSystem.Play();

            //test if the enemies hit is higher than the most damaged in a single attack record previously
            if (unit.playerID == 0 && enemiesHit > StatisticsTracker.mostUnitsDamagedWithOneAttack)
            {
                StatisticsTracker.mostUnitsDamagedWithOneAttack = enemiesHit;
            }

            applied = true;
        }

        AnimatorStateInfo info = unit.ArtLink.GetCurrentAnimatorStateInfo(0);

        //check that the attack animation has ended
        if (info.normalizedTime >= 1.0f)
        {
            //reset the direction override
            unit.GetComponentInChildren <FaceMovement>().directionOverride = Vector3.zero;
            successCallback();
        }
    }
Beispiel #7
0
 public FuzzyResultBuilder CustomMembership(GetArea membershipFunction)
 {
     this.areaFunction = membershipFunction;
     return(this);
 }
        public ActionResult PostShopData()
        {
            int      shopid = DoRequest.GetFormInt("shopid");
            ShopInfo shop   = GetShopDetail.Do(shopid).Body;

            if (shop == null)
            {
                shop         = new ShopInfo();
                shop.shop_id = 0;
            }
            shop.shop_name    = DoRequest.GetFormString("shopName");
            shop.company_name = DoRequest.GetFormString("Company");
            shop.shop_key     = DoRequest.GetFormString("skeyword");

            string pswd = DoRequest.GetFormString("spsword");

            if ((pswd.Equals("") || pswd == null) && shop.shop_id == 0)
            {
                return(Json(new { error = true, message = "[密码] 不能为空" }));
            }
            if (!pswd.Equals("") && pswd != null)
            {
                shop.shop_pswd = AES.Decode2(pswd, "5f9bf958d112f8668ac53389df8bceba");
            }
            int province = DoRequest.GetFormInt("province");
            int city     = DoRequest.GetFormInt("city");

            shop.area_id   = province;
            shop.shop_addr = GetArea.Do(province).Body.area_list[0].area_name;
            string cityName = GetArea.Do(city).Body.area_list[0].area_name;

            if (!cityName.StartsWith("市辖") && !cityName.StartsWith("直辖"))
            {
                shop.shop_addr += cityName;
            }
            shop.link_way        = DoRequest.GetFormString("linkway");
            shop.support_express = DoRequest.GetFormString("supportexpress");
            shop.delivery_intro  = DoRequest.GetFormString("deliveryintro");
            shop.service_intro   = DoRequest.GetFormString("serviceintro", false);

            string   sdate     = DoRequest.GetFormString("sdate").Trim();
            int      shours    = DoRequest.GetFormInt("shours");
            int      sminutes  = DoRequest.GetFormInt("sminutes");
            DateTime startDate = Utils.IsDateString(sdate) ? DateTime.Parse(sdate + " " + shours + ":" + sminutes + ":00") : DateTime.Now;

            string   edate    = DoRequest.GetFormString("edate").Trim();
            int      ehours   = DoRequest.GetFormInt("ehours");
            int      eminutes = DoRequest.GetFormInt("eminutes");
            DateTime endDate  = Utils.IsDateString(edate) ? DateTime.Parse(edate + " " + ehours + ":" + eminutes + ":59") : DateTime.Now.AddDays(7);

            shop.notice_btime = startDate.ToString("yyyy-MM-dd HH:mm:ss");
            shop.notice_etime = endDate.ToString("yyyy-MM-dd HH:mm:ss");
            shop.shop_notice  = DoRequest.GetFormString("shopnotice", false);
            shop.shop_remark  = DoRequest.GetFormString("remarks");
            shop.shop_type    = DoRequest.GetFormInt("shoptype");
            #region Checking
            if (shop.shop_name.Length < 1)
            {
                return(Json(new { error = true, message = "[店铺名称] 不能为空" }));
            }
            if (shop.shop_name.Length > 50)
            {
                return(Json(new { error = true, message = "[店铺名称] 不能大于50个字符" }));
            }
            if (shop.company_name.Length < 0 && shop.company_name.Length > 100)
            {
                return(Json(new { error = true, message = "[公司名称] 不能为空或大于100个字符" }));
            }
            if (shop.shop_key.Length < 1)
            {
                return(Json(new { error = true, message = "[账号] 不能为空" }));
            }
            if (shop.shop_pswd.Length < 1)
            {
                return(Json(new { error = true, message = "[密码] 不能为空" }));
            }
            if (shop.area_id < 0)
            {
                return(Json(new { error = true, message = "[发货地址] 不能为空" }));
            }
            if (shop.shop_addr.Length < 1)
            {
                return(Json(new { error = true, message = "[联系方式] 不能为空" }));
            }
            if (shop.support_express.Length < 1)
            {
                return(Json(new { error = true, message = "[快递公司] 不能为空" }));
            }
            #endregion

            int returnValue = -1;
            var res         = OpShopInfo.Do(shop);
            if (res != null && res.Header != null && res.Header.Result != null && res.Header.Result.Code != null)
            {
                returnValue = Utils.StrToInt(res.Header.Result.Code, -1);
            }

            if (returnValue == 0)
            {
                DoCache cache = new DoCache();
                cache.RemoveCache("shoplist");
                return(Json(new { error = false, message = "操作成功" }));
            }
            return(Json(new { error = true, message = "操作失败" }));
        }
 public override double Area()
 {
     GetArea?.Invoke();
     return(Math.Abs((Points[0].X - Points[2].X) * (Points[1].Y - Points[2].Y) -
                     (Points[1].X - Points[2].X) * (Points[0].Y - Points[2].Y)) / 2);
 }
Beispiel #10
0
    /*
     * ExecAttack
     *
     * fuzzy function for attacking the enemy with the (most health x potential DPS)
     *
     * @param BaseInput inp - the object containing useful data that the function uses to determine what to do
     * @returns void
     */
    public void ExecAttack(BaseInput inp)
    {
        //up-cast the base input
        ManagerInput minp = inp as ManagerInput;

        //don't do anything if the unit cannot attack
        if (minp.unit.hasAttacked)
        {
            return;
        }

        //get a list of walkable tiles around the unit
        List <Tiles> attackable = GetArea.GetAreaOfAttack(map.GetTileAtPos(minp.unit.transform.position), minp.unit.attackRange, map);

        //worst possible score to start
        float bestScore = -1.0f;

        //reference to the best tile that has been found
        Tiles bestTile = null;

        //get the size of the walkable list
        int attackSize = attackable.Count;

        //iterate through all walkable tiles
        for (int i = 0; i < attackSize; i++)
        {
            //store in a temp variable
            Tiles tile = attackable[i];

            //does the tile contain an enemy
            if (tile.unit != null)
            {
                if (tile.unit.playerID != playerID)
                {
                    //health ratio * damage per turn / max health
                    float threatScore = (tile.unit.health / tile.unit.maxHealth) * tile.unit.damage / tile.unit.maxHealth;

                    if (bestScore < threatScore)
                    {
                        //reassign the best score
                        bestTile  = tile;
                        bestScore = threatScore;
                    }
                }
            }
        }

        //attack the best tile if one is found
        if (bestTile != null)
        {
            Attack(minp.unit, bestTile.pos);
        }
        else
        {
            //get the worst threat and move towards it
            Unit  bestTarget      = null;
            float bestThreatScore = -1.0f;

            //get the size of the players list
            int playerSize = minp.manager.players.Count;

            //iterate through all players except for this one, getting the average of all enemies
            for (int i = 0; i < playerSize; i++)
            {
                //store in a temp variable
                BasePlayer bp = minp.manager.players[i];

                if (bp.playerID == playerID)
                {
                    continue;
                }

                //get the size of the player's units array
                int unitCount = bp.units.Count;

                //check for visibility and count
                for (int j = 0; j < unitCount; j++)
                {
                    if (bp.units[j].inSight)
                    {
                        //store in a temp variable
                        Unit unit = bp.units[j];

                        //the unit is in sight, consider it a threat
                        float threatScore = (unit.health / unit.maxHealth) * unit.damage;

                        //reset the score
                        if (bestThreatScore < threatScore)
                        {
                            bestTarget      = unit;
                            bestThreatScore = threatScore;
                        }
                    }
                }
            }

            if (bestTarget != null)
            {
                //don't do anything if the unit has run out of points
                if (minp.unit.movementPoints == 0)
                {
                    return;
                }

                ExecuteMovementGivenTarget(minp.unit, bestTarget.transform.position);
            }
        }
    }
Beispiel #11
0
 public override double Area()
 {
     GetArea?.Invoke(this, null);
     return(Math.Round(Width() * Width(), 2));
 }
    /*
     * Update
     * overrides UnitCommand's Update()
     *
     * called once per frame while the command is active
     *
     * @returns void
     */
    public override void Update()
    {
        if (m_tilePath == null)
        {
            //get the start and end of the path
            Tiles startingTile = map.GetTileAtPos(unit.transform.position);

            startingTile.unit = null;

            //get the tile path to follow
            if (isSafeMove)
            {
                m_tilePath = AStar.GetSafeAStarPath(startingTile, endTile, unit, GetArea.GetAreaOfSafeMoveable(startingTile, unit.movementPoints, map, unit));
            }
            else
            {
                m_tilePath = AStar.GetAStarPath(startingTile, endTile, unit);
            }

            //the path is clear, and the unit can move there
            if (m_tilePath.Count > 0 && m_tilePath.Count <= unit.movementPoints)
            {
                //subtract the path distance from the movement points
                unit.movementPoints -= m_tilePath.Count;

                startingTile.unit = null;
                endTile.unit      = unit;
            }
            else
            {
                //Stop walking Anim
                if (unit.ArtLink != null)
                {
                    unit.ArtLink.SetBool("IsWalking", false);
                }

                //the path failed
                startingTile.unit = unit;
                failedCallback();
                return;
            }
        }

        m_timer += Time.deltaTime;

        //check if there is still a path to follow
        if (m_tilePath.Count > 0 && m_timer > m_waitTime)
        {
            if (m_finishedWaiting == false)
            {
                m_finishedWaiting = true;

                if (unit.ArtLink != null)
                {
                    unit.ArtLink.SetBool("IsWalking", true);
                }
            }

            //get the next position to go to
            Tiles nextTile = m_tilePath[0];

            //the 3D target of the movement
            Vector3 target = new Vector3(nextTile.pos.x, 0.15f, nextTile.pos.z);

            Vector3 relative = target - unit.transform.position;

            if (relative.magnitude < unit.movementSpeed * Time.deltaTime)
            {
                //this is a healing tile, heal the unit
                if (nextTile.IsHealing(false, unit))
                {
                    unit.Heal(GameManagment.stats.tileHealthGained);
                }

                //this is a trap tile, it could kill the unit
                if (nextTile.tileType == eTileType.PLACABLETRAP || nextTile.tileType == eTileType.DAMAGE)
                {
                    m_timer           = 0;
                    m_finishedWaiting = false;

                    if (unit.ArtLink != null)
                    {
                        unit.ArtLink.SetTrigger("TakeDamage");
                    }

                    unit.Defend(GameManagment.stats.trapTileDamage);

                    //explosion is required
                    if (nextTile.tileType == eTileType.PLACABLETRAP)
                    {
                        //reset the explosion
                        ParticleLibrary.explosionSystem.transform.position = nextTile.transform.position;
                        ParticleLibrary.explosionSystem.time = 0.0f;
                        ParticleLibrary.explosionSystem.Play();
                    }

                    //Stop walking Anim
                    if (unit.ArtLink != null)
                    {
                        unit.ArtLink.SetBool("IsWalking", false);
                    }
                }

                unit.transform.position = target;
                m_tilePath.RemoveAt(0);

                if (unit.playerID == 0)
                {
                    StatisticsTracker.tilesCrossed++;
                }
            }
            else
            {
                unit.transform.position += relative.normalized * unit.movementSpeed * Time.deltaTime;
            }
        }
        else if (m_timer > m_waitTime)
        {
            if (endTile.tileType == eTileType.PLACABLEDEFENSE || endTile.tileType == eTileType.DEFENSE)
            {
                //defensive buff
                endTile.unit.armour = endTile.unit.baseArmour + 1;
            }
            else
            {
                //remove the defensive buff
                endTile.unit.armour = endTile.unit.baseArmour;
            }
            successCallback();

            //Stop walking Anim
            if (unit.ArtLink != null)
            {
                unit.ArtLink.SetBool("IsWalking", false);
            }

            return;
        }
    }