コード例 #1
0
    public override void initImage(Arg aArg, string aDirectory)
    {
        createChild();
        mTileList = new List <MapTile>();
        string tFileName = aDirectory + "/" + aArg.get <string>("file");
        List <List <List <int> > > tTileData = aArg.get <List <List <List <int> > > >("tiles");
        float tWidth  = tTileData[0].Count;
        float tHeight = tTileData.Count;

        for (int tY = 0; tY < tTileData.Count; tY++)
        {
            List <List <int> > tLine = tTileData[tY];
            for (int tX = 0; tX < tLine.Count; tX++)
            {
                List <int> tChip = tLine[tX];
                if (tChip[0] == -1)
                {
                    continue;
                }
                Sprite  tSprite = ChipLoader.load(tFileName, tChip[0], tChip[1]);
                MapTile tTile   = MyBehaviour.create <MapTile>();
                tTile.init(tSprite, new MapBehaviourAttribute(MapBehaviourAttribute.Attribute.accessory));
                tTile.transform.position = new Vector3(tX - tWidth / 2 + 0.5f, tHeight - tY - 0.5f, 0);
                mTileList.Add(tTile);
                tTile.gameObject.transform.SetParent(mChild.transform, false);
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// 影を生成してfieldに追加
    /// </summary>
    /// <param name="aData">影のデータ</param>
    private static void buildShadow(MapFileData.Shadow aData)
    {
        List <Vector3>     tPositionList = aData.mPosition;
        MyTag              tColliderTag  = aData.mCollider;
        ImageShadowTrigger tShadow;
        LieMesh            tMesh;
        Vector3            tOffset = aData.mOffset;
        MapCell            tCell;
        MapTile            tTile;

        foreach (Vector3 tPosition in tPositionList)
        {
            //追加対象のtile
            tCell = mWorld.mCells[Mathf.FloorToInt(tPosition.x), Mathf.FloorToInt(tPosition.y), Mathf.FloorToInt(tPosition.z)];
            tTile = (tPosition.z.decimalPart() > 0.4f) ? tCell.mHalfHeightTile : tCell.mTile;

            tShadow      = MyBehaviour.create <ImageShadowTrigger>();
            tShadow.name = "shadow(" + tPosition.x + "," + tPosition.y + "," + tPosition.z + ")";
            //shadePower
            tShadow.mShadePower = aData.mShadePower;
            //position
            tShadow.mMapPosition = new MapPosition(tTile.mMapPosition.vector + tOffset, 1);
            //sprite
            tMesh             = tShadow.createChild <LieMesh>();
            tMesh.mRenderMode = Mesh2D.RenderMode.shadow;
            tMesh.mSprite     = Resources.Load <Sprite>(MyMap.mMapResourcesDirectory + "/sprites/" + aData.mSpritePath);
            tMesh.initialize();
            tMesh.setColor(new Color(0, 0, 0, aData.mShadePower));
            //collider
            Collider2DCreator.addCollider(tShadow.gameObject, tColliderTag);
            //追加
            tShadow.transform.SetParent(mWorld.mStratums[Mathf.FloorToInt(tPosition.z)].mShadows.transform, false);
            tShadow.changeLayer(MyMap.mStratumLayerNum[Mathf.FloorToInt(tPosition.z)], true);
        }
    }
コード例 #3
0
 ///画像を表示するための子要素生成
 protected void createChild()
 {
     mChild      = MyBehaviour.create <MyBehaviour>().gameObject;
     mChild.name = "sprites";
     mChild.transform.localPosition = new Vector3(0, 0, 0);
     mChild.transform.SetParent(gameObject.transform, false);
 }
コード例 #4
0
    ///<summary>指定階層のstratum生成してworldに追加</summary>
    static private void buildStratum(int aStratumLevel)
    {
        MapFileData.Stratum tStratumData = mData.mStratums[aStratumLevel];

        MapStratum tStratum = MyBehaviour.create <MapStratum>();

        tStratum.name = "stratum" + aStratumLevel.ToString();

        tStratum.changeLayer(MyMap.mStratumLayerNum[aStratumLevel], false);
        tStratum.transform.SetParent(mWorld.mField.transform, false);
        mWorld.mStratums[aStratumLevel] = tStratum;

        //マス生成
        List <List <int> > tFeildData = tStratumData.mFeild;
        int tXLength = tFeildData[0].Count;
        int tZLength = tFeildData.Count;

        for (int tZ = 0; tZ < tZLength; tZ++)
        {
            for (int tX = 0; tX < tXLength; tX++)
            {
                buildCell(tX, aStratumLevel, tZ);
            }
        }
    }
コード例 #5
0
    /// <summary>
    /// SEを再生する
    /// </summary>
    /// <param name="aFileName">ファイルへのパス("resources/sound/se" + X)</param>
    static public void playSe(string aFileName)
    {
        //音声ロード
        AudioSource tAudio = MyBehaviour.create <AudioSource>();

        tAudio.name = "SE : " + aFileName;
        tAudio.clip = Resources.Load <AudioClip>("sound/se/" + aFileName);
        if (tAudio.clip == null)
        {
            //音声のロードに失敗
            Debug.Log("音声のロードに失敗 : " + "「sound/se/" + aFileName + "」");
            return;
        }
        tAudio.Play();
        //再生終了したら削除
        MyBehaviour tBehaviour = tAudio.gameObject.AddComponent <MyBehaviour>();
        Coroutine   tCoroutine = null;

        tCoroutine = tBehaviour.runCoroutine(() => {
            if (!tAudio.isPlaying)
            {
                tBehaviour.StopCoroutine(tCoroutine);
                tBehaviour.delete();
            }
        });
    }
コード例 #6
0
    /// <summary>食糧取得or損失アニメーション</summary>
    public static void getFood(PlayerStatusDisplay aDisplay, int aFood, Action aCallback)
    {
        TextMesh tMesh = MyBehaviour.create <TextMesh>();

        tMesh.text               = (aFood >= 0 ? "+" : "") + aFood.ToString();
        tMesh.name               = "getFoodMesh : " + tMesh.text;
        tMesh.fontSize           = 100;
        tMesh.characterSize      = 0.04f;
        tMesh.anchor             = TextAnchor.MiddleLeft;
        tMesh.transform.position = new Vector3(aDisplay.positionX - 0.6f, aDisplay.positionY - 0.1f, -20);
        Vector2 tDirection;

        if (aFood >= 0)
        {
            //取得
            tMesh.color = new Color(0, 1, 1);
            tDirection  = new Vector2(0, 0.3f);
        }
        else
        {
            //損失
            tMesh.color = new Color(1, 0, 0);
            tDirection  = new Vector2(0, -0.3f);
        }
        MyBehaviour tBehaviour = tMesh.gameObject.AddComponent <MyBehaviour>();

        tBehaviour.moveBy(tDirection, 1.2f, () => {
            tBehaviour.delete();
            aCallback();
        });
    }
コード例 #7
0
ファイル: KeyNotePlayer.cs プロジェクト: tTomonori/KeyNote
 public KeyNotePlayer(MusicScore aScore, MusicPlayer aPlayer)
 {
     mBehaviour      = MyBehaviour.create <MyBehaviour>();
     mBehaviour.name = "KeyNotePlayer's CoroutineRunner";
     mScore          = aScore;
     mPlayer         = aPlayer;
 }
コード例 #8
0
ファイル: MySoundPlayer.cs プロジェクト: tTomonori/animalKing
    /// <summary>
    /// BGMを再生する
    /// </summary>
    /// <param name="aFilePath">resources/sound/bgm/ + aFilePath</param>
    public static void playBgm(string aFilePath, LoopType aLoopType = LoopType.normalConnect, float aVolume = 1)
    {
        if (mBgm == null)
        {
            mBgm      = MyBehaviour.create <AudioSource>();
            mBgm.name = "BGM AudioSource";
            mBgm.gameObject.AddComponent <MyBehaviour>();
            GameObject.DontDestroyOnLoad(mBgm);
        }

        mBgm.clip   = Resources.Load <AudioClip>("sound/bgm/" + aFilePath);
        mBgm.time   = 0;
        mBgm.volume = aVolume;
        mBgm.Play();
        MyBehaviour tBehaviour = mBgm.gameObject.GetComponent <MyBehaviour>();

        if (mBgmLoopCoroutine != null)
        {
            tBehaviour.StopCoroutine(mBgmLoopCoroutine);
        }
        switch (aLoopType)
        {
        case LoopType.normalConnect:
            mBgmLoopType      = aLoopType;
            mBgmLoopCoroutine = tBehaviour.StartCoroutine(runNormalConnect(mBgm));
            break;
        }
    }
コード例 #9
0
    ///マス生成
    static public MapTrout create(List <Arg> aChip)
    {
        MapTrout              tTrout              = MyBehaviour.create <MapTrout>();
        List <Arg>            tMasDataList        = new List <Arg>();                                         //マスのタイル情報リスト
        MapAttributeBehaviour tAttributeBehaviour = tTrout.gameObject.AddComponent <MapAttributeBehaviour>(); //マップ属性

        tAttributeBehaviour.setAttribute(MapBehaviourAttribute.Attribute.none);                               //マップ属性の初期値をnoneに設定
        //マスのタイル情報を読んでリストに
        foreach (Arg tData in aChip)
        {
            Arg tMasData = loadMasData(tData.get <string>("file"), tData.get <int>("x"), tData.get <int>("y"));
            tMasData.set("file", tData.get <string>("file"));
            tMasDataList.Add(tMasData);
            //マップ属性を重ねる
            tAttributeBehaviour.mAttribute.pile(tMasData.get <string>("attribute"));
        }
        //画像設定
        ChildSprite.addSpriteObject(tTrout.gameObject, new Arg(new Dictionary <string, object>()
        {
            { "pile", tMasDataList }
        }), kDirPath);
        //collider設定
        if (tAttributeBehaviour.mAttribute.attribute != MapBehaviourAttribute.Attribute.flat &&
            tAttributeBehaviour.mAttribute.attribute != MapBehaviourAttribute.Attribute.none)
        {
            BoxCollider2D tBox = tTrout.gameObject.AddComponent <BoxCollider2D>();
            tBox.size = new Vector2(1, 1);
        }
        return(tTrout);
    }
コード例 #10
0
ファイル: MeasureBpmMain.cs プロジェクト: tTomonori/KeyNote
    void Start()
    {
        Arg tArg = MySceneManager.getArg("measureBpm");

        mStartMeasureTime = tArg.get <float>("second");
        //テキストオブジェクト取得
        mMarginText    = GameObject.Find("measuredMarginLabel").GetComponent <MyBehaviour>().findChild <TextMesh>("value");
        mBpmText       = GameObject.Find("measuredBpmLabel").GetComponent <MyBehaviour>().findChild <TextMesh>("value");
        mStaticBpmText = GameObject.Find("measuredStaticMarginLabel").GetComponent <MyBehaviour>().findChild <TextMesh>("value");
        //audio用意
        mPlayer = MyBehaviour.create <MusicPlayer>();
        mPlayer.setAudio(DataFolder.loadMusic(MusicScoreData.mMusicFileName));
        //margin計算で固定で使うbpm
        mStaticBpm = tArg.get <float>("staticBpm");
        GameObject.Find("measuredStaticMarginLabel").GetComponent <MyBehaviour>().findChild <TextMesh>("bpm").text = "(" + mStaticBpm.ToString() + " BPM)";

        Subject.addObserver(new Observer("measureBpmMain", (message) => {
            if (message.name == "endMeasureBpmButtonPushed")
            {
                MySceneManager.closeScene("measureBpm");
                return;
            }
            if (message.name == "restartMeasureBpmButtonPushed")
            {
                restartMeasure();
                return;
            }
        }));
        restartMeasure();
    }
コード例 #11
0
    /// <summary>文字mesh生成</summary>
    private TextMeshPro createTextMesh()
    {
        TextMeshPro tP = MyBehaviour.create <TextMeshPro>();

        tP.rectTransform.sizeDelta = new Vector2(1, 1);
        tP.rectTransform.pivot     = new Vector2(0.5f, 0.5f);
        tP.font     = _DefaultFontAsset;
        tP.fontSize = kUnitFontSize * mCurrentFontHeight;
        tP.color    = mCurrentFontColor;
        switch (_CharacterAlign)
        {
        case CharacterAlign.middle:
            tP.alignment = TextAlignmentOptions.Center;
            break;

        case CharacterAlign.midLine:
            tP.alignment = TextAlignmentOptions.Midline;
            break;

        case CharacterAlign.capLine:
            tP.alignment = TextAlignmentOptions.Capline;
            break;
        }
        return(tP);
    }
コード例 #12
0
ファイル: MusicScore.cs プロジェクト: tTomonori/KeyNote
 private void Start()
 {
     for (int i = mCurrentBarNum - 4; i < mCurrentBarNum + 5; i++)
     {
         mBars.Add(createBar(new KeyTime(i)));
     }
     mMetro = MyBehaviour.create <MetroArrow>();
     mMetro.setParentScore(this);
 }
コード例 #13
0
 private void Awake()
 {
     //テキスト表示領域生成
     mBoard = MyBehaviour.create <MyTextBoard>();
     mBoard.transform.SetParent(this.transform, false);
     mBoard.name  = this.name + ":TextBoard";
     mBoard.mFont = mFont;
     adjustBoardSize();
 }
コード例 #14
0
    static public MapCharacter create(string aAiName, string aSpriteFileName, Direction aDirection, string aName = "", Vector2?aColliderSize = null)
    {
        if (aColliderSize == null)
        {
            aColliderSize = new Vector2(0.6f, 0.3f);
        }
        //画像
        Sprite tOrigen = Resources.Load <Sprite>("Sprites/character/" + aSpriteFileName);

        Sprite[,] tSprites = new Sprite[3, 4];
        for (int x = 0; x < 3; x++)
        {
            for (int y = 0; y < 4; y++)
            {
                tSprites[x, y] = SpriteCutter.Create(tOrigen.texture, new Rect(x * 100, y * 100, 100, 100), new Vector2(0.5f, 0f), 80);
            }
        }
        Dictionary <string, List <Sprite> > tDic = new Dictionary <string, List <Sprite> >();

        tDic["standUp"] = new List <Sprite>()
        {
            tSprites[1, 0]
        };
        tDic["standDown"] = new List <Sprite>()
        {
            tSprites[1, 3]
        };
        tDic["standLeft"] = new List <Sprite>()
        {
            tSprites[1, 2]
        };
        tDic["standRight"] = new List <Sprite>()
        {
            tSprites[1, 1]
        };
        tDic["moveUp"] = new List <Sprite>()
        {
            tSprites[0, 0], tSprites[1, 0], tSprites[2, 0], tSprites[1, 0]
        };
        tDic["moveDown"] = new List <Sprite>()
        {
            tSprites[0, 3], tSprites[1, 3], tSprites[2, 3], tSprites[1, 3]
        };
        tDic["moveLeft"] = new List <Sprite>()
        {
            tSprites[0, 2], tSprites[1, 2], tSprites[2, 2], tSprites[1, 2]
        };
        tDic["moveRight"] = new List <Sprite>()
        {
            tSprites[0, 1], tSprites[1, 1], tSprites[2, 1], tSprites[1, 1]
        };
        MapCharacter tCharacter = MyBehaviour.create <MapCharacter>();

        tCharacter.init(aAiName, tDic, (Vector2)aColliderSize, aDirection, aName);
        return(tCharacter);
    }
コード例 #15
0
    static public MapCamera init(MapWorld aWorld)
    {
        MapCamera tCamera = MyBehaviour.create <MapCamera>();

        tCamera.mWorld    = aWorld;
        tCamera.mCamera   = tCamera.createChildCamera(aWorld.mSize.y);
        tCamera.mConfig   = new MapCameraConfig();
        tCamera.positionZ = -10;
        return(tCamera);
    }
コード例 #16
0
 public override void initImage(Arg aArg, string aDirectory)
 {
     createChild();
     foreach (Arg tData in aArg.get <List <Arg> >("pile"))
     {
         GameObject tObject = MyBehaviour.create <MyBehaviour>().gameObject;
         tObject.transform.SetParent(mChild.gameObject.transform, false);
         ChildSprite.addSpriteObject(tObject, tData, aDirectory);
     }
 }
コード例 #17
0
 public override void hold()
 {
     mLight      = MyBehaviour.create <MyBehaviour>();
     mLight.name = "light";
     mLight.gameObject.AddComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>("sprites/button/electro/light");
     mLight.transform.parent        = this.gameObject.transform;
     mLight.transform.localPosition = new Vector3(0, 0, -1);
     mLight.transform.localScale    = new Vector3(1, 1, 1);
     mLight.rotateZ = Random.Range(0, 359);
     mLight.rotateForever(-180f);
 }
コード例 #18
0
    private Image createImage(string aPath)
    {
        Image tImage = MyBehaviour.create <Image>();

        tImage.sprite = Resources.Load <Sprite>(aPath);
        tImage.rectTransform.sizeDelta  = new Vector2(tImage.sprite.texture.texelSize.x / tImage.sprite.texture.texelSize.y, 1);
        tImage.rectTransform.localScale = new Vector3(1 / kScale, 1 / kScale, 1 / kScale);
        tImage.rectTransform.pivot      = new Vector2(0, 1);
        tImage.gameObject.layer         = gameObject.layer;
        return(tImage);
    }
コード例 #19
0
 private void uniteChildren()
 {
     mContentsObject = MyBehaviour.create <MyBehaviour>();
     mContents.name  = "buttonContents";
     mContents.transform.SetParent(this.transform, false);
     //子要素を一つのbehaviourにまとめる
     foreach (Transform tChild in GetComponentsInChildren <Transform>())
     {
         tChild.SetParent(mContents.transform, true);
     }
 }
コード例 #20
0
    //新しい行を生成
    private void createNewLine()
    {
        RectTransform tRect = MyBehaviour.create <RectTransform>();

        tRect.name      = "line";
        tRect.sizeDelta = new Vector2(mRect.sizeDelta.x, 1);
        Line tLine = new Line(tRect);

        tLine.mPositionY = (mLines.Count == 0) ? 0 : mLines[0].getBottom();
        tRect.SetParent(mLineContainer, false);
        mLines.Insert(0, tLine);
    }
コード例 #21
0
ファイル: PlayMain.cs プロジェクト: tTomonori/KeyNote
    void Start()
    {
        Arg tArg = MySceneManager.getArg("play");
        //Arg tArg = new Arg(new Dictionary<string, object>() { { "file", "kawaikunaritai" }, { "difficult", "guru" } });
        string         tFileName  = tArg.get <string>("file");
        ScoreDifficult tDifficult = tArg.get <ScoreDifficult>("difficult");

        mHandler = MyBehaviour.create <ScoreHandler>();
        mHandler.load(tFileName, tDifficult);
        mHandler.show(new KeyTime(-3));
        mHandler.changeState(new ScoreHandler.PlayState(mHandler));
    }
コード例 #22
0
        static public StringElement create(string aString, MeshTextBoard aParent)
        {
            StringElement aElement = MyBehaviour.create <StringElement>();

            aElement.name      = aString;
            aElement.mPro      = aParent.createTextMesh();
            aElement.mPro.text = aString;
            aElement.mWidth    = aElement.mPro.preferredWidth;
            aElement.mHeight   = aParent.mCurrentFontHeight;
            aElement.mPro.transform.SetParent(aElement.transform, false);
            return(aElement);
        }
コード例 #23
0
    public static MyBehaviour placeRoute(Vector2 aPosition1, Vector2 aPosition2)
    {
        MyBehaviour    tRoute    = MyBehaviour.create <MyBehaviour>();
        SpriteRenderer tRenderer = tRoute.gameObject.AddComponent <SpriteRenderer>();

        tRoute.name       = "route";
        tRenderer.sprite  = Resources.Load <Sprite>("tile");
        tRoute.scaleX     = Vector2.Distance(aPosition1, aPosition2) * 10;
        tRoute.position2D = (aPosition1 + aPosition2) / 2.0f;
        tRoute.rotateZ    = new Vector2(1, 0).corner(aPosition2 - aPosition1);
        return(tRoute);
    }
コード例 #24
0
    public static MasDisplay[] placeMas(StageData aData)
    {
        //ルート(白い線)の入れ物
        MyBehaviour tRouteContainer = MyBehaviour.create <MyBehaviour>();

        tRouteContainer.positionZ = 0.5f;
        MyBehaviour tRoute;

        tRouteContainer.name = "routeContainer";
        //マスの入れ物
        MyBehaviour tMasContainer = MyButton.create <MyBehaviour>();

        tMasContainer.name = "masContainer";

        List <StageData.Mas> tMasDataList = aData.mMas;

        MasDisplay[] tDisplay = new MasDisplay[tMasDataList.Count];
        MasDisplay   tPrefab  = Resources.Load <MasDisplay>("prefab/game/mas/land");

        for (int i = 0; i < tMasDataList.Count; i++)
        {
            switch (tMasDataList[i].mType)
            {
            case MasStatus.MasType.land:
                tDisplay[i] = GameObject.Instantiate <MasDisplay>(tPrefab);
                break;

            case MasStatus.MasType.start:
                tDisplay[i] = GameObject.Instantiate <MasDisplay>(Resources.Load <MasDisplay>("prefab/game/mas/start"));
                break;

            case MasStatus.MasType.accident:
                tDisplay[i] = GameObject.Instantiate <MasDisplay>(Resources.Load <MasDisplay>("prefab/game/mas/" + ((StageData.Accident)tMasDataList[i]).mAccidentType));
                break;

            default:
                throw new System.Exception("GamePlacer : 不正な土地属性");
            }
            tDisplay[i].position2D       = tMasDataList[i].position;
            tDisplay[i].transform.parent = tMasContainer.transform;
            //ルート配置
            if (i != 0)
            {
                tRoute = placeRoute(tDisplay[i - 1].position2D, tDisplay[i].position2D);
                tRoute.transform.SetParent(tRouteContainer.transform, false);
            }
        }
        //最初のマスと最後のマスのルート配置
        tRoute = placeRoute(tDisplay[tMasDataList.Count - 1].position2D, tDisplay[0].position2D);
        tRoute.transform.parent = tRouteContainer.transform;
        return(tDisplay);
    }
コード例 #25
0
    //<summary>トリガー生成</summary>
    static public MapTrigger createTrigger(MapFileData.Trigger aData)
    {
        MapKeyEventTrigger tTrigger = MyBehaviour.create <MapKeyEventTrigger>();

        //形状
        MyTag tShapeTag = aData.mShape;

        switch (tShapeTag.mTagName)
        {
        case "cube":    //立方体
            BoxCollider tBox = tTrigger.gameObject.AddComponent <BoxCollider>();
            tBox.size   = new Vector3(float.Parse(tShapeTag.mArguments[0]), float.Parse(tShapeTag.mArguments[1]), float.Parse(tShapeTag.mArguments[1]));
            tBox.center = new Vector3(0, tBox.size.y / 2f, 0);
            break;

        default:
            throw new System.Exception("MapWorldFactory-TriggerFactory : 不正な形状名「" + tShapeTag.mTagName + "」");
        }

        //triggerKey
        tTrigger.mTriggerKey = aData.mTriggerKey;
        //eventKey
        tTrigger.mEnterKey = aData.mEnterKey;
        tTrigger.mStayKey  = aData.mStayKey;
        tTrigger.mMovedKey = aData.mMovedKey;
        tTrigger.mExitKey  = aData.mExitKey;
        //collisionType
        switch (aData.mCollisionType)
        {
        case "pass":
            tTrigger.mCollisionType = MapPhysics.CollisionType.pass;
            break;

        case "stop":
            tTrigger.mCollisionType = MapPhysics.CollisionType.stop;
            break;

        case "collide":
            tTrigger.mCollisionType = MapPhysics.CollisionType.collide;
            break;

        default:
            Debug.LogWarning("triggerFactory : 不正なcollisionType「" + aData.mCollisionType + "」");
            break;
        }
        //attribute
        TriggerPhysicsAttribute tAttribute = tTrigger.gameObject.AddComponent <TriggerPhysicsAttribute>();

        tAttribute.mTrigger = tTrigger;

        return(tTrigger);
    }
コード例 #26
0
ファイル: ScoreHandleState.cs プロジェクト: tTomonori/KeyNote
        //音符を消した時の演出
        protected void productHit(Note aNote, TypeEvaluation.Evaluation aEvaluation)
        {
            //評価表示オブジェクト生成
            MyBehaviour tBehaviour = MyBehaviour.create <MyBehaviour>();

            tBehaviour.name = "evaluation";
            SpriteRenderer tRenderer = tBehaviour.gameObject.AddComponent <SpriteRenderer>();

            tBehaviour.transform.parent        = parent.mScore.transform;
            tBehaviour.transform.localScale    = new Vector3(1.7f, 1.7f, 1);
            tBehaviour.transform.localPosition = new Vector3(0, 0, 0);
            tBehaviour.transform.Translate(aNote.transform.position - parent.mScore.transform.position);
            tBehaviour.positionZ = -2;
            //sprite設定とアニメーション
            switch (aEvaluation)
            {
            case TypeEvaluation.Evaluation.perfect:
                tRenderer.sprite = Resources.Load <Sprite>("sprites/point/perfect");
                tBehaviour.moveBy(new Vector3(0, 1, 0), 1, () => {
                    tBehaviour.delete();
                });
                break;

            case TypeEvaluation.Evaluation.great:
                tRenderer.sprite = Resources.Load <Sprite>("sprites/point/great");
                tBehaviour.moveBy(new Vector3(0, 0.6f, 0), 1, () => {
                    tBehaviour.delete();
                });
                break;

            case TypeEvaluation.Evaluation.good:
                tRenderer.sprite = Resources.Load <Sprite>("sprites/point/good");
                tBehaviour.moveBy(new Vector3(0, 0.4f, 0), 1, () => {
                    tBehaviour.delete();
                });
                break;

            case TypeEvaluation.Evaluation.bad:
                tRenderer.sprite = Resources.Load <Sprite>("sprites/point/bad");
                tBehaviour.moveBy(new Vector3(0, 0.1f, 0), 1, () => {
                    tBehaviour.delete();
                });
                break;

            case TypeEvaluation.Evaluation.miss:
                tRenderer.sprite = Resources.Load <Sprite>("sprites/point/miss");
                tBehaviour.moveBy(new Vector3(0, -1, 0), 1, () => {
                    tBehaviour.delete();
                });
                break;
            }
        }
コード例 #27
0
    public void init(MyScrollViewElementDataList aDataList, Option aOption)
    {
        if (mOption != null)
        {
            return;
        }
        mOption = aOption;
        //オプション調整
        if (mOption.infinitScrool)
        {
            mOption.sortable = false;                       //無限スクロールがonならソート機能は使えない
        }
        if (!mOption.sortable)
        {
            mOption.doubleTapSort = false; //ソート機能がoffならダブルタップでのソート機能もoff
        }
        if (!mOption.doubleTap)            //ダブルタップがoff
        {
            mOption.doubleTapTime = 0;
            mOption.doubleTapSort = false;
        }
        //マスク
        gameObject.AddComponent <RectMask2D>();
        RectTransform tRect = gameObject.GetComponent <RectTransform>();

        tRect.sizeDelta = mOption.contentSize;
        tRect.pivot     = new Vector2(0, 1);

        mDataList = aDataList;
        mState    = new MyScrollViewWaitState(this);
        //可視部分collider
        MyBehaviour tColliderBehaviour = MyBehaviour.create <MyBehaviour>();

        tColliderBehaviour.name             = "myScrollViewContentCollider";
        tColliderBehaviour.transform.parent = this.transform;
        tColliderBehaviour.position         = new Vector3(0, 0, 0);
        tColliderBehaviour.scale            = new Vector3(1, 1, 1);
        mCollider        = tColliderBehaviour.gameObject.AddComponent <BoxCollider2D>();
        mCollider.size   = mOption.contentSize;
        mCollider.offset = new Vector2(mOption.contentSize.x / 2, -mOption.contentSize.y / 2);
        //表示領域
        mContent                  = MyBehaviour.create <MyBehaviour>();
        mContent.name             = "myScrollViewContent";
        mContent.transform.parent = this.gameObject.transform;
        mContent.position         = new Vector3(0, 0, -0.1f);
        mContent.scale            = new Vector3(1, 1, 1);
        //要素リスト
        mElements = new List <ElementTuple>();

        initElements();
    }
コード例 #28
0
 //背景画像設定
 public void setBackground(Sprite aSprite)
 {
     if (mBackground == null)
     {
         MyBehaviour tBackground = MyBehaviour.create <MyBehaviour>();
         tBackground.name             = "background";
         tBackground.transform.parent = this.transform;
         tBackground.position         = new Vector3(0, 0, 10);
         mBackground       = tBackground.gameObject.AddComponent <SpriteRenderer>();
         mBackground.color = new Color(0.8f, 0.8f, 0.8f);
     }
     mBackground.sprite = aSprite;
     mBackground.transform.localScale = new Vector3(16 / aSprite.bounds.size.x, 16 / aSprite.bounds.size.x, 1);
 }
コード例 #29
0
        static public ImageElement create(string aPath, MeshTextBoard aParent)
        {
            ImageElement aElement = MyBehaviour.create <ImageElement>();

            aElement.name             = "image:" + aPath;
            aElement.mRenderer        = aElement.createChild <SpriteRenderer>();
            aElement.mRenderer.sprite = Resources.Load <Sprite>(aPath);
            aElement.mHeight          = aParent.mCurrentFontHeight;
            aElement.mWidth           = aElement.mHeight * (aElement.mRenderer.sprite.bounds.size.x / aElement.mRenderer.sprite.bounds.size.y);
            float tScale = aElement.mHeight / aElement.mRenderer.sprite.bounds.size.y;

            aElement.mRenderer.transform.localScale = new Vector3(tScale, tScale, 1);
            return(aElement);
        }
コード例 #30
0
ファイル: MySoundPlayer.cs プロジェクト: tTomonori/animalKing
    /// <summary>
    /// SEを再生する
    /// </summary>
    /// <param name="aFilePath">resources/sound/se/ + aFilePath</param>
    /// <param name="aAllowOverlap">falseの場合は同じSEを同時に鳴らそうとすると前のSEを停止する</param>
    public static void playSe(string aFilePath, bool aAllowOverlap = false, float aVolume = 1)
    {
        if (mSe == null)
        {
            mSe = new Dictionary <string, SoundSet>();
        }
        AudioSource tAudio;
        MyBehaviour tBehaviour;

        if (aAllowOverlap)
        {
            //同時再生可
            tAudio        = MyBehaviour.create <AudioSource>();
            tAudio.clip   = Resources.Load <AudioClip>("sound/se/" + aFilePath);
            tAudio.name   = "SE : " + aFilePath;
            tAudio.volume = aVolume;
            tAudio.Play();
            tBehaviour = tAudio.gameObject.AddComponent <MyBehaviour>();
            tBehaviour.StartCoroutine(deleteSe(tAudio, ""));
            return;
        }
        else
        {
            //同時再生不可
            if (mSe.ContainsKey(aFilePath))
            {
                //同時再生しようとした
                SoundSet tPlayedSet = mSe[aFilePath];
                tPlayedSet.mSound.clip = Resources.Load <AudioClip>("sound/se/" + aFilePath);
                tPlayedSet.mSound.time = 0;
                tPlayedSet.mSound.Play();
                return;
            }
            else
            {
                tAudio        = MyBehaviour.create <AudioSource>();
                tAudio.clip   = Resources.Load <AudioClip>("sound/se/" + aFilePath);
                tAudio.name   = "SE : " + aFilePath;
                tAudio.volume = aVolume;
                tAudio.Play();
                tBehaviour = tAudio.gameObject.AddComponent <MyBehaviour>();
                SoundSet tSet = new SoundSet();
                tSet.mSound     = tAudio;
                tSet.mCoroutine = tBehaviour.StartCoroutine(deleteSe(tAudio, aFilePath));
                mSe.Add(aFilePath, tSet);
                GameObject.DontDestroyOnLoad(tAudio);
            }
        }
    }