예제 #1
0
    /// <summary>
    /// 切换地块
    /// </summary>
    /// <param name="coordinate"></param>
    public static void SwitchTile(Vector2 coordinate)
    {
        int key = GetTileIdByCoordinate(coordinate);

        if (tileMap.ContainsKey(key))
        {
            currentTile = tileMap[key];
        }
        else
        {
            currentTile = AddTileJson(key);
        }
        FreshData();
        NotiCenter.DispatchEvent(KCEvent.KCTileChange);
    }
예제 #2
0
    /// <summary>
    /// 1对1
    /// </summary>
    /// <param name="json">数据类</param>
    public static void VSOne(HeroJson hero)
    {
        int userAtt = 10;

        hero.hp -= userAtt;
        //刷文本
        hero.view.preHPChangeValue = -userAtt;
        NotiCenter.DispatchEvent(KCEvent.KCHeroHPChange, (object)hero.view);

        if (hero.hp > 0)
        {
            hero.view.Fresh(FreshType.Hp);
            return;
        }
        //死亡
        hero.hp = 0;
        hero.view.Fresh(FreshType.Hp);
        hero.view.Fresh(FreshType.Die);
        ItemsModel.AddItems(hero.items);
    }
예제 #3
0
 /// <summary>
 /// 向用户数据中添加道具
 /// </summary>
 public static void AddItems(int[] items)
 {
     for (int i = 0; i < items.Length; i++)
     {
         ItemJson newItem = itemMap.ContainsKey(items[i]) ? itemMap[items[i]] : AddItemJson(items[i].ToString());
         if (userItemMap.ContainsKey(items[i])) //已经有道具了
         {
             //1.替换
             userItemMap[items[i]] = newItem;
             //2叠加耐久
             userItemMap[items[i]].durable += newItem.durable;
             //3.舍弃
         }
         else
         {
             userItemMap.Add(items[i], newItem); //还没有道具
         }
     }
     NotiCenter.DispatchEvent(KCEvent.KCItemsChange, (object)items);
 }