示例#1
0
    static void PaintCaseB()
    {
        // 赤色
        string[] reds = new string[]
        {
            "Cubes/キューブ1x2",
            "Cubes/キューブ1x3",
            "Cubes/キューブ2x3",
        };
        // 青色
        string[] blues = new string[]
        {
            "Cubes/キューブ2x1",
            "Cubes/キューブ3x1",
            "Cubes/キューブ3x2",
        };

        Material redMtl  = ResourceManager.GetMaterial(ResourceManager.nd_red_name);
        Material blueMtl = ResourceManager.GetMaterial(ResourceManager.nd_blue_name);

        foreach (string cubeName in reds)
        {
            GameObjectCreator.PaintGameObject(cubeName, redMtl);
        }

        foreach (string cubeName in blues)
        {
            GameObjectCreator.PaintGameObject(cubeName, blueMtl);
        }
    }
示例#2
0
    public static void Clear()
    {
        var allObjects = FindObjectsOfType <GameObject>();

        foreach (var go in allObjects)
        {
            GameObjectCreator.DestroyGameObject(go);
        }

        /*
         * // ヒエラルキー・ウィンドウに出てこない隠れているオブジェクトも全部消すぜ☆(^~^)
         * // 参考Webサイト
         * //      2014年01月11日「How do I remove a Game Object that is not visible in the hierarchy?」unity
         * //      https://answers.unity.com/questions/613728/how-do-i-remove-a-game-object-that-is-not-visible.html
         *
         * var allObjects = FindObjectsOfType<GameObject>();
         * foreach (var go in allObjects)
         * {
         *  if ((go.hideFlags & HideFlags.HideInHierarchy) != 0)
         *  {
         *      GameObjectCreator.DestroyGameObject(go);
         *  }
         * }
         */
    }
示例#3
0
 // Update is called once per frame
 void Update()
 {
     timer++;
     if (timer == 150)
     {
         mainScript.start();
         Destroy(parent);
         Destroy(this);
     }
     if (hasJumped && hasDucked && timer > 150)
     {
         timer = 0;
         return;
     }
     if (playerScript.isJumping == true && !hasJumped)
     {
         hasJumped = true;
         GameObjectCreator.createSprite(new Vector2(6.7f, 1.1f), checkBox, false).transform.parent = parent.transform;
     }
     if (playerScript.isDucking == true && !hasDucked)
     {
         hasDucked = true;
         GameObjectCreator.createSprite(new Vector2(7.1f, 0.1f), checkBox, false).transform.parent = parent.transform;
     }
 }
    void Start()
    {
        PlayerPrefs.DeleteAll();
        gameOverBoard = GameObject.Find(CommandWords.GAMEOVERBOARD);

        loadSprites("Ground", 4, groundSprites);
        loadSprites("Cloud", 3, cloudSprites);
        loadSprites("Bush", 3, bushSprites);

        g            = GameObject.Find(CommandWords.PLAYEROBJECT);
        playerScript = g.GetComponent <Player>();
        airPlane     = GameObject.Find("Airplane").GetComponent <Animator>();
        scoreText    = GameObject.Find("ScoreObject").GetComponent <TextMesh>();

        float[] positions = { -3.5f, 7.75f, 19 };
        foreach (float positionX in positions)
        {
            GameObjectCreator.createSprite(new Vector2(positionX, -2.9f), groundSprites[0], true);
        }

        listener = new KeywordRecognizer(words);
        listener.OnPhraseRecognized += recognize;
        listener.Start();
        colorMap.Add(CommandWords.YELLOW, Color.yellow);
        colorMap.Add(CommandWords.RED, Color.red);
        colorMap.Add(CommandWords.PURPLE, Color.magenta);
        colorMap.Add(CommandWords.PINK, new Color(1, 0, 0.5f));
        colorMap.Add(CommandWords.BROWN, new Color(0.56f, 0.43f, 0.3f));

        highScore = PlayerPrefs.GetInt(CommandWords.HIGHSCORE + "1", 0);
    }
示例#5
0
    static void PaintRightBottomWingBlue()
    {
        Material mtl = ResourceManager.GetMaterial(ResourceManager.nd_blue_name);

        string[] names = GetCubeNames("right_bottom_wing");
        foreach (string name in names)
        {
            GameObjectCreator.PaintGameObject(name, mtl);
        }
    }
示例#6
0
    static void PaintLeftTopWingRed()
    {
        Material mtl = ResourceManager.GetMaterial(ResourceManager.nd_red_name);

        string[] names = GetCubeNames("left_top_wing");
        foreach (string name in names)
        {
            GameObjectCreator.PaintGameObject(name, mtl);
        }
    }
示例#7
0
    static void PaintAllWhite()
    {
        Material mtl = ResourceManager.GetMaterial(ResourceManager.nd_white_name);

        string[] names = GetCubeNames("all");
        foreach (string name in names)
        {
            GameObjectCreator.PaintGameObject(name, mtl);
        }
    }
示例#8
0
    static void PaintDiagonal()
    {
        Material mtl = ResourceManager.GetMaterial(ResourceManager.nd_red_name);

        string[] names = GetCubeNames("square");
        foreach (string name in names)
        {
            GameObjectCreator.PaintGameObject(name, mtl);
        }
    }
示例#9
0
    static void Clear()
    {
        GameObject cubesObj = GameObject.Find("Cubes");

        if (null != cubesObj)
        {
            // 既存なら消す☆(^~^)
            GameObjectCreator.DestroyGameObject(cubesObj);
            Debug.Log("既存のCubesオブジェクトは消したぜ☆(^~^)");
        }
    }
示例#10
0
    public static void CreatePrefubCube()
    {
        ResourceManager.ReadyDirectory();

        string     prefabCubeName = string.Format("{0}/{1}", ResourceManager.nd_prefabs, ResourceManager.nd_cube_name);
        GameObject prefabCube     = (GameObject)Resources.Load(prefabCubeName);

        if (null != prefabCube)
        {
            Debug.Log(string.Format("キューブのプレファブはもうある☆(^~^) path={0}", prefabCubeName));
            return;
        }
        Debug.Log(string.Format("キューブのプレファブが無いんで、作るぜ☆(^~^) path={0}", prefabCubeName));


        // ********************************************************************************
        // * プレファブ作成                                                               *
        // ********************************************************************************
        // ヒエラルキーには見えない一時ゲームオブジェクトを作る(このオブジェクトはあとで破棄する)
        GameObject expectedTmpObj = EditorUtility.CreateGameObjectWithHideFlags("Expected Cube", HideFlags.HideInHierarchy,
                                                                                typeof(UnityEngine.MeshFilter),
                                                                                typeof(UnityEngine.BoxCollider),
                                                                                typeof(UnityEngine.MeshRenderer)
                                                                                );


        // Unityデフォルトのキューブを作成
        GameObject defaultCube = GameObject.CreatePrimitive(UnityEngine.PrimitiveType.Cube);


        // Cube (メッシュ・フィルター)
        {
            // デフォルトのキューブから、メッシュをもらう
            expectedTmpObj.GetComponent <UnityEngine.MeshFilter>().mesh = defaultCube.GetComponent <MeshFilter>().sharedMesh;
        }

        // メッシュ・レンダラー
        {
            // デフォルトのキューブのメッシュ・レンダラーから、マテリアルをもらう
            expectedTmpObj.GetComponent <MeshRenderer>().material = defaultCube.GetComponent <MeshRenderer>().sharedMaterial;
        }


        // キューブのプレファブを作成する
        PrefabUtility.CreatePrefab(string.Format("{0}/{1}/{2}/{3}", ResourceManager.nd_assets, ResourceManager.nd_resources, ResourceManager.nd_prefabs, ResourceManager.nd_cube_file), expectedTmpObj);

        // Unityデフォルトのキューブを削除
        GameObjectCreator.DestroyGameObject(defaultCube);

        // プレファブの元は破棄する
        GameObjectCreator.DestroyGameObject(expectedTmpObj);
    }
示例#11
0
    static void CreateKuku()
    {
        ResourceManager.CreateMaterials();

        for (int z = 1; z < 11; z++)
        {
            for (int x = 1; x < 11; x++)
            {
                float height = x * z;
                GameObjectCreator.CreateCube(string.Format("キューブ{0}x{1}", x, z), x, height / 2, z, 1.0f, height, 1.0f);
            }
        }
    }
示例#12
0
 void Start()
 {
     checkBox     = Resources.Load <Sprite>(CommandWords.CHECKBOX);
     mainScript   = gameObject.AddComponent <Main>();
     playerScript = GameObject.Find(CommandWords.PLAYEROBJECT).GetComponent <Player>();
     if (PlayerPrefs.GetInt(CommandWords.HIGHSCORE + "1") != 0)
     {
         mainScript.start();
         Destroy(this);
     }
     else
     {
         parent = new GameObject();
         parent.transform.position = new Vector2(-3.9f, 1.5f);
         GameObjectCreator.createText(new Vector2(-3.7f, 1.4f), "Press the up arrow or say \"jump\" into the mic").transform.parent   = parent.transform;
         GameObjectCreator.createText(new Vector2(-3.7f, 0.4f), "Press the down arrow or say \"duck\" into the mic").transform.parent = parent.transform;
     }
 }
    private void spawnObstacle()
    {
        int action = Random.Range(0, 4);

        if (action == 3)
        {
            airPlane.SetTrigger("AIRPLANE");
            spawnObstacleTimer += 500;
        }
        else
        {
            int amountOfObstacles = Random.Range(1, 3);
            for (int i = 0; i < amountOfObstacles; i++)
            {
                GameObject  g    = GameObjectCreator.createSprite(new Vector2(10 + i * 2, -1.83f), bushSprites[action], true);
                Rigidbody2D body = g.AddComponent <Rigidbody2D>();
                body.isKinematic = true;
                g.AddComponent <BoxCollider2D>();
            }
            spawnObstacleTimer += Random.Range(150, 250);
        }
    }
 private void spawnGround()
 {
     GameObjectCreator.createSprite(new Vector2(19f, -2.9f), groundSprites[Random.Range(0, 4)], true);
 }
 private void spawnCloud()
 {
     GameObjectCreator.createSprite(new Vector2(19f, 2.5f), cloudSprites[Random.Range(0, 3)], true);
     cloudSpawnTimer += Random.Range(30, 70);
 }
示例#16
0
 public static void Clear()
 {
     ResourceManager.Clear();
     GameObjectCreator.Clear();
 }
示例#17
0
    static void PaintCaseA()
    {
        /*
         * // 例
         * string[] names = new string[]
         * {
         *  "Cubes/キューブ2x6",
         *  "Cubes/キューブ2x7",
         *  "Cubes/キューブ2x8",
         *  "Cubes/キューブ2x9",
         *  "Cubes/キューブ3x7",
         *  "Cubes/キューブ5x5",
         *  "Cubes/キューブ7x4",
         *  "Cubes/キューブ8x4",
         *  "Cubes/キューブ9x4",
         *  "Cubes/キューブ10x4",
         * };
         */
        //*
        // 例 平方数
        string[] names = new string[]
        {
            "Cubes/キューブ1x1",
            "Cubes/キューブ2x2",
            "Cubes/キューブ3x3",
            "Cubes/キューブ4x4",
            "Cubes/キューブ5x5",
            "Cubes/キューブ6x6",
            "Cubes/キューブ7x7",
            "Cubes/キューブ8x8",
            "Cubes/キューブ9x9",
            "Cubes/キューブ10x10",
        };
        // */

        /*
         * // 例 上の方の平方数の近く
         * string[] names = new string[]
         * {
         *  "Cubes/キューブ6x5",
         *  "Cubes/キューブ6x6",
         *  "Cubes/キューブ7x6",
         *  "Cubes/キューブ7x7",
         *  "Cubes/キューブ8x7",
         *  "Cubes/キューブ8x8",
         *  "Cubes/キューブ9x8",
         *  "Cubes/キューブ9x9",
         *  "Cubes/キューブ10x9",
         *  "Cubes/キューブ10x10",
         * };
         */
        /*
         * // 例 素数
         * string[] names = new string[]
         * {
         *  "Cubes/キューブ1x2",
         *  "Cubes/キューブ1x3",
         *  "Cubes/キューブ1x5",
         *  "Cubes/キューブ1x7",
         *  "Cubes/キューブ2x1",
         *  "Cubes/キューブ3x1",
         *  "Cubes/キューブ5x1",
         *  "Cubes/キューブ7x1",
         * };
         */

        string   namePath = string.Format("{0}/{1}", ResourceManager.nd_materials, ResourceManager.nd_red_name);
        Material mtl      = Resources.Load <Material>(namePath);

        Debug.Assert(null != mtl, string.Format("path={0} Redマテリアル作ってないだろ☆(^~^)", namePath));

        foreach (string name in names)
        {
            GameObjectCreator.PaintGameObject(name, mtl);
        }
    }
示例#18
0
 static void SetVisibleAllCubes()
 {
     string[] names = GetCubeNames("all");
     GameObjectCreator.SetVisibleAllGameObjects(names, true);
 }
示例#19
0
 static void SetVisible1x1Cube()
 {
     string[] names = GetCubeNames("1x1cube");
     GameObjectCreator.SetVisibleAllGameObjects(names, true);
 }