Exemplo n.º 1
0
    public void LoadResReturnWWW(string name, Action <WWW> callback)
    {
        string path = MyUnityTools.AppContentPath() + name;

        Debug.Log("加载:" + path);
        StartCoroutine(LoaderRes(path, callback));
    }
Exemplo n.º 2
0
 public virtual void init(int type, Vector2 minPos, Vector2 maxPos)
 {
     MyUnityTools.dflt(ref lm, "LevelController");
     //pseudo-constructor
     //initialize a newly spawned ghost from script
     Type = type;
     transform.position = new Vector2(UnityEngine.Random.Range(minPos.x, maxPos.x),
                                      UnityEngine.Random.Range(minPos.y, maxPos.y));
 }
Exemplo n.º 3
0
    public Text goScoreText; //GameOver...

    void Awake()
    {
        Debug.Log("Het is wel aan het starten!");
        //initialize the elements array
        elements = GetComponentsInChildren <Graphic>();
        //initize special elemets; its repeat code I know, its a gamejam get off my back
        MyUnityTools.dflt(ref scoreText, "ScoreText");
        MyUnityTools.dflt(ref typeIcon, "TypeIcon");
        MyUnityTools.dflt(ref timerText, "TimerText");
        MyUnityTools.dflt(ref gameOver, "GameOver");
        MyUnityTools.dflt(ref goScoreText, "GO_ScoreText");
        MyUnityTools.dflt(ref splash, "Splash");
    }
Exemplo n.º 4
0
    int[] presentTypes()
    {
        /*
         * returns a list of all types present in the current ghosts
         */
        var typesFound = new HashSet <int>();

        GameObject[] ghosts = GameObject.FindGameObjectsWithTag("Ghost");
        foreach (GameObject ghost in ghosts)
        {
            Debug.Log(ghost);
            typesFound.Add(ghost.GetComponent <Ghost>().Type);
        }
        Debug.Log("Found " + typesFound.Count + " types.");
        return(MyUnityTools.ToArray(typesFound));
    }
Exemplo n.º 5
0
 // Use this for initialization
 void Start()
 {
     Debug.Log("Het is wel aan het starten!");
     spawnGhosts(startingGhosts);
     MyUnityTools.dflt(ref hud, "TopBar");
     MyUnityTools.dflt(ref pointsPopup, "PointsPopup");
     Debug.Log("Het is nog steds aan het starten!");
     //because gamejam;
     typeIcons = new Sprite[baseNumTypes] {
         policeSprt,   //Resources.Load<Sprite>("Sprites/ghost_police_hat"), //cyan //0
         magicSprt,    //1
         construcSprt, //2
         armySprt,     //3
         chefSprt,     //4
         cowSprt       //5
     };
     reset();
 }
Exemplo n.º 6
0
    void Awake()
    {
        //ignor that this is in Dutch...
        //Debug.Log("Het is wel aan het starten!");

        //defaults for variables
        MyUnityTools.dflt(ref text, "SplashText");
        MyUnityTools.dflt(ref image, "SplashImage");

        /*
         * }
         *
         * void Start(){
         */
        //become invisible
        //Debug.Log("Turning splash elements off.");
        image.gameObject.SetActive(false);
        text.gameObject.SetActive(false);
        //Debug.Log("Splash elemenents are " + image.gameObject.activeSelf.ToString() + "," + text.gameObject.activeSelf.ToString());
    }
Exemplo n.º 7
0
    /// <summary>
    /// 释放资源,把streamasset下的资源拷贝到平台对应的沙盒目录
    /// </summary>
    IEnumerator OnExtractResource()
    {
        string resPath  = MyUnityTools.AppContentPath(); //游戏包资源目录
        string dataPath = MyUnityTools.DataPath;         //数据目录

        if (Directory.Exists(dataPath))
        {
            Directory.Delete(dataPath, true);
        }

        Directory.CreateDirectory(dataPath);

        string infile  = resPath + m_versionTxtName;
        string outfile = dataPath + m_versionTxtName;

        if (File.Exists(outfile))
        {
            File.Delete(outfile);
        }

        string message = "正在解包文件:>" + m_versionTxtName;

        Debug.Log("infile:" + infile);
        Debug.Log("outfile:" + outfile);
        Debug.Log(message);
        //dispatcher.Dispatch (NotiConst.UPDATE_MESSAGE, message);

        //只有Android平台要流方式www,其它平台都可以IO方式
        if (Application.platform == RuntimePlatform.Android)
        {
            WWW www = new WWW(infile);
            yield return(www);

            if (www.isDone)
            {
                File.WriteAllBytes(outfile, www.bytes);
            }
            yield return(0);
        }
        else
        {
            File.Copy(infile, outfile, true);
        }

        yield return(new WaitForEndOfFrame());

        //释放所有文件到数据目录
        string[] files = File.ReadAllLines(outfile);
        for (int i = 0; i < files.Length; i++)
        {
            if (i == 0) //第一行不处理
            {
                continue;
            }

            string   file = files[i];
            string[] fs   = file.Split('|');

            infile  = resPath + fs[0];
            outfile = dataPath + fs[0];

            message = "正在解包文件:>" + fs[0];
            Debug.Log("正在解包文件:>" + infile);
            //dispatcher.Dispatch (NotiConst.UPDATE_MESSAGE, message);

            string dir = Path.GetDirectoryName(outfile);
            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            if (Application.platform == RuntimePlatform.Android)
            {
                WWW www = new WWW(infile);
                yield return(www);

                if (www.isDone)
                {
                    File.WriteAllBytes(outfile, www.bytes);
                }
                yield return(0);
            }
            else
            {
                if (File.Exists(outfile))
                {
                    File.Delete(outfile);
                }
                File.Copy(infile, outfile, true);
            }
            yield return(new WaitForEndOfFrame());
        }
        message = "解包完成!!!";
        Debug.Log(message);
        //dispatcher.Dispatch (NotiConst.UPDATE_MESSAGE,"");
        //dispatcher.Dispatch (NotiConst.UPDATE_STATE, message);
        //dispatcher.Dispatch (NotiConst.UPDATE_PROGRESS, 0.5f);

        yield return(new WaitForSeconds(0.1f));

        message = string.Empty;

        //释放完成,开始启动更新资源
        StartUpdateVersion();
    }
Exemplo n.º 8
0
 protected void Awake()
 {
     MyUnityTools.dflt(ref lm, "LevelController");
 }
Exemplo n.º 9
0
 void Start()
 {
     MyUnityTools.dflt(ref mainButtons, "MainButtons");
     MyUnityTools.dflt(ref credits, "Credits");
 }