Beispiel #1
0
    //mission fish
    public static List <FishData> getMissionFishList(MissionFishData data)
    {
        List <FishData> fishList = new  List <FishData>();
        Vector2         bounds   = GameController.WorldBound;
        FishItemSpec    spec     = SpecController.getItemById(data.item_id) as FishItemSpec;
        GameObject      fishObj  = GameController.GetInstance().getPrefab(spec.name);
        string          lC       = data.levelCount;

        string[] arr = lC.Split(new char[1] {
            '|'
        });
        float t = bounds.x * 0.1f;

        for (int j = 0; j < arr.Length; j++)
        {
            string[] arr1 = arr[j].Split(new char[1] {
                ':'
            });
            int c = Mathf.FloorToInt(int.Parse(arr1 [1]) / 2) + 1;
            for (int i = 0; i < c; i++)
            {
                if (i == 0)
                {
                    fishList.Add(new FishData(spec, new Vector3(0, -1, 0), new Vector3(0, bounds.y * 1.2f, 0), j * 2 + (i + 1) * 0.5f, 50, 0));
                }
                else
                {
                    fishList.Add(new FishData(spec, new Vector3(0, -1, 0), new Vector3(i * t, bounds.y * 1.2f, 0), j * 2 + (i + 1) * 0.5f, 50, 0));
                    fishList.Add(new FishData(spec, new Vector3(0, -1, 0), new Vector3(-i * t, bounds.y * 1.2f, 0), j * 2 + (i + 1) * 0.5f, 50, 0));
                }
            }
        }
        return(fishList);
    }
    public void init(HomeObject obj)
    {
        hObject = obj;
        FishItemSpec spec = SpecController.getItemById(obj.trappedId) as FishItemSpec;

        transform.Find("Fish").GetComponent <Animator> ().Play(spec.name);
    }
Beispiel #3
0
    void creatRewards()
    {
        rewardList = new Dictionary <string, int> ();
        if (taskId == "random")
        {
            int expCount = 0;
            int coin     = 0;
            foreach (TaskItem item in requireList.Values)
            {
                FishItemSpec fSpec = SpecController.getItemById(item.item_id) as FishItemSpec;
                expCount += fSpec.common * 5;
                coin     += fSpec.coin * item.total * 2;
            }

            rewardList.Add("exp", expCount);
            rewardList.Add("coin", coin);
        }
        else
        {
            List <OwnedItem> specrewardList = getTaskSpec().getRewardList();
            foreach (OwnedItem item in specrewardList)
            {
                rewardList.Add(item.item_id, item.count);
            }
        }
        setSaveData();
    }
Beispiel #4
0
    public static string getRanFishId()
    {
        int[]        ratCommon = { 20, 20, 20, 20 };
        FishItemSpec spec      = getRandFishId(ratCommon);

        return(spec.item_id);
    }
Beispiel #5
0
    public static string getRanPetEggId()
    {
        int[]        ratCommon = { 80, 30, 5 };
        FishItemSpec spec      = getRandFishId(ratCommon);

        return(spec.item_id);
    }
Beispiel #6
0
 private FishItemSpec getSpec()
 {
     if (spec == null)
     {
         spec = SpecController.getItemById(item_id) as FishItemSpec;
     }
     return(spec);
 }
 public FishItemSpec getSpec()
 {
     if (_spec == null)
     {
         _spec = SpecController.getItemById(item_id) as FishItemSpec;
     }
     return(_spec);
 }
    public void init(MissionFishData data, Vector3 _landPos)
    {
        fishData = data;
        FishItemSpec spec = SpecController.getItemById(data.item_id) as FishItemSpec;

        transform.Find("Fish").GetComponent <Animator> ().Play(spec.name);
        landPos = _landPos;
        mainRig = GetComponent <Rigidbody2D> ();
        getNewForce();
    }
    public void init(MissionFishData data)
    {
        fishData = data;
        FishItemSpec spec = SpecController.getItemById(data.item_id) as FishItemSpec;

        if (spec != null)
        {
            transform.Find("Icon").GetComponent <Image> ().sprite = GameController.GetInstance().getSpByName("Pic/ui/" + spec.name + "Icon");
        }

        EndTimeText = transform.Find("TimeText").GetComponent <Text> ();
        GameObject render   = transform.Find("FishPart").Find("Render").gameObject;
        GameObject listView = transform.Find("FishPart").Find("Viewport").gameObject;

        for (int i = 0; i < listView.transform.childCount; i++)
        {
            GameObject go = listView.transform.GetChild(i).gameObject;
            Destroy(go);
        }

        string lC = data.levelCount;

        string[] arr = lC.Split(new char[1] {
            '|'
        });
        foreach (string str in arr)
        {
            string[] arr1 = str.Split(new char[1] {
                ':'
            });
            GameObject newRender = Instantiate(render);
            newRender.GetComponent <RectTransform>().SetParent(listView.GetComponent <RectTransform>());
            newRender.GetComponent <RectTransform>().localScale    = Vector3.one;          //调整大小
            newRender.GetComponent <RectTransform>().localPosition = Vector3.zero;         //调整位置
            newRender.SetActive(true);

            newRender.transform.Find("LevelText").GetComponent <Text> ().text = arr1 [0].ToString();
            newRender.transform.Find("Text").GetComponent <Text> ().text      = "×" + arr1 [1].ToString();
            newRender.transform.Find("Icon").GetComponent <Image> ().sprite   = GameController.GetInstance().getSpByName("Pic/ui/" + spec.name + "Icon");
        }

        int   t = arr.Length;
        float h = Mathf.Max(t * 60 + (t - 1) * 5 + 20, 240);

        listView.GetComponent <RectTransform>().sizeDelta = new Vector2(280, h);
        listView.transform.Translate(new Vector3(0, -h / 2, 0));

        refreshEndTime();
    }
    public FishData(FishItemSpec _spec, Vector3 _direction, Vector3 _position, float time, int _setSpeed, int _repeatTime)
    {
        spec       = _spec;
        item_id    = _spec.item_id;
        fishName   = spec.name;
        direction  = _direction;
        position   = _position;
        creatTime  = time;
        heart      = spec.coin;
        speed      = _setSpeed;
        repeatTime = _repeatTime;
        curBlood   = spec.Blood;
        float tar = Mathf.Atan2(_direction.y, _direction.x) * Mathf.Rad2Deg + 180f;

        fishRot = Quaternion.Slerp(Quaternion.identity, Quaternion.Euler(0, 0, tar), 3f);
    }
    Dictionary <string, ItemSpec> getFishTypes(string landName)
    {
        Dictionary <string, ItemSpec> fishes = SpecController.getGroup("Fish");

        Dictionary <string, ItemSpec> newFishes = new Dictionary <string, ItemSpec> ();

        foreach (string key in fishes.Keys)
        {
            FishItemSpec spec = fishes[key] as FishItemSpec;
            if (spec.common == 1 || spec.common == 2 || spec.common == 3)
            {
                newFishes.Add(key, spec);
            }
        }

        return(newFishes);
    }
Beispiel #12
0
    public static Dictionary <string, TaskItem> getRanTaskFishList()
    {
        int m = Random.Range(1, 2);
        Dictionary <string, TaskItem> fishDic = new Dictionary <string, TaskItem> ();

        while (m > 0)
        {
            int[]        ratCommon = { 80, 30, 5 };
            Vector2      bounds    = GameController.WorldBound;
            FishItemSpec spec      = getRandFishId(ratCommon);

            int count = 10;
            if (spec.common == 1)
            {
                count = Random.Range(30, 50);
            }
            else if (spec.common == 2)
            {
                count = Random.Range(10, 20);
            }
            else if (spec.common == 3)
            {
                count = Random.Range(5, 10);
            }

            TaskItem item = new TaskItem();
            item.item_id  = spec.item_id;
            item.finished = 0;
            item.total    = count;

            if (fishDic.ContainsKey(spec.item_id))
            {
                continue;
            }
            else
            {
                fishDic.Add(spec.item_id, item);
            }

            m--;
        }

        return(fishDic);
    }
 public void init(string fishId, float _maxCount)
 {
     spec     = SpecController.getItemById(fishId) as FishItemSpec;
     maxCount = _maxCount;
 }
Beispiel #14
0
    //随机刷

    private static List <FishData> randList()
    {
        List <FishData> fishList = new  List <FishData>();

        int[]        ratCommon = { 80, 30, 5 };
        Vector2      bounds    = GameController.WorldBound;
        FishItemSpec spec      = getRandFishId(ratCommon);

        int count = 1;

        if (spec.common == 1)
        {
            count = Random.Range(3, 8);
        }
        else if (spec.common == 2)
        {
            count = Random.Range(1, 3);
        }
        float   r = Random.value;
        Vector3 pos;
        Vector2 pivatVec;

        if (r > 0.6)
        {
            //left
            pos      = new Vector3(-bounds.x * 1.2f, Random.Range(-bounds.y * 0.8f, bounds.y * 0.8f), 0);
            pivatVec = new Vector2(-1f, 0);
        }
        else if (r > 0.2)
        {
            //right
            pos      = new Vector3(bounds.x * 1.2f, Random.Range(-bounds.y * 0.8f, bounds.y * 0.8f), 0);
            pivatVec = new Vector2(1f, 0);
        }
        else if (r > 0.1)
        {
            //top
            pos      = new Vector3(Random.Range(-bounds.x * 1.5f, bounds.x * 1.5f), bounds.y * 1.2f, 0);
            pivatVec = new Vector2(0, 1f);
        }
        else
        {
            //bottom
            pos      = new Vector3(Random.Range(-bounds.x * 1.5f, bounds.x * 1.5f), -bounds.y * 1.2f, 0);
            pivatVec = new Vector2(0, -1f);
        }

        Vector3 tarPos     = new Vector3(Random.Range(-bounds.x * 0.5f, bounds.x * 0.5f), Random.Range(-bounds.y * 0.5f, bounds.y * 0.5f), 0);
        Vector3 direction  = (tarPos - pos).normalized;
        float   fishPivate = Random.value * 0.4f + 0.4f;

        float px;
        float py;

        for (int i = 0; i < count; i++)
        {
            if (pivatVec.x == 0)
            {
                px = Random.value - 0.5f;
                py = pivatVec.y;
            }
            else
            {
                px = pivatVec.x;
                py = Random.value - 0.5f;
            }

            Vector3 curPos = new Vector3(pos.x + i * fishPivate * px, pos.y + i * fishPivate * py, 0);
            fishList.Add(new FishData(spec, direction, curPos, 1f, 0, 2));
        }
        return(fishList);
    }