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); } } }
public KeyNotePlayer(MusicScore aScore, MusicPlayer aPlayer) { mBehaviour = MyBehaviour.create <MyBehaviour>(); mBehaviour.name = "KeyNotePlayer's CoroutineRunner"; mScore = aScore; mPlayer = aPlayer; }
void CheckTimer() { if (this._actionTimer < 0) { switch (this._currentBehaviour) { case MyBehaviour.Idle: this._currentBehaviour = MyBehaviour.Ponder; this._actionTimer = this._ponderTimer; this._destinationAngle = Random.Range(0, 360); break; case MyBehaviour.Ponder: this._currentBehaviour = MyBehaviour.Turning; this._actionTimer = this._turningTimer; break; case MyBehaviour.Turning: this._currentBehaviour = MyBehaviour.Walking; this._actionTimer = this._walkingTimer; break; case MyBehaviour.Walking: this._currentBehaviour = MyBehaviour.Idle; this._actionTimer = this._idleTimerStarts + Random.Range(0, 1.5f); break; } } }
///画像を表示するための子要素生成 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); }
/// <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(); } }); }
/// <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(); }); }
///<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); } } }
/// <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; } }
/// <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); } }
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(); }
///マス生成 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); }
//小節生成 private Bar createBar(KeyTime aBarNum) { Bar tBar = MyBehaviour.createObjectFromPrefab <Bar>("score/bar" + MusicScoreData.mRhythm.ToString()); tBar.mTime = aBarNum; //音符追加 List <Arg> tNotes = MusicScoreData.getNotesInBar(aBarNum); foreach (Arg tNoteData in tNotes) { tBar.addNote(tNoteData); } //歌詞追加 List <Arg> tLyrics = MusicScoreData.getLyricsInBar(aBarNum); foreach (Arg tLyricsData in tLyrics) { tBar.addLyrics(tLyricsData); } //bpm変化を示すオブジェクト追加 List <Arg> tBpms = MusicScoreData.getChangeBpmInBar(aBarNum); foreach (Arg tBpm in tBpms) { tBar.addChangeBpm(tBpm); } //位置調整 tBar.transform.parent = gameObject.transform; tBar.transform.localPosition = new Vector3(0, convertToPositionY(tBar.mTime.mBarNum), 0); tBar.transform.localScale = new Vector3(1f, 1f, 1f); tBar.name = "bar:" + aBarNum.mBarNum; return(tBar); }
///<summary>キャラクター生成</summary> static public MapCharacter createCharacter(MapFileData.Character aData) { MapCharacter tCharacter = MyBehaviour.createObjectFromResources <MapCharacter>(MyMap.mMapResourcesDirectory + "/character/" + aData.mPath); //名前 tCharacter.mName = aData.mName; tCharacter.name = "character:" + aData.mName; //向き tCharacter.mCharacterRenderBehaviour.mImage.setDirection(aData.mDirection); //ai tCharacter.setAi(createAi(aData.mAi)); //state tCharacter.transitionState(createState(aData.mState)); //movingData tCharacter.mMovingData = new MovingData(); tCharacter.mMovingData.mSpeed = aData.mMoveSpeed; Vector3 tColliderSize = tCharacter.mEntityPhysicsBehaviour.mAttriubteCollider.minimumCircumscribedCube(); tCharacter.mMovingData.mDeltaDistance = Mathf.Min(tColliderSize.x, tColliderSize.z); //speaker if (aData.mIsSpeaker) { MapKeyEventSpeaker tSpeaker = tCharacter.mEntityPhysicsBehaviour.mAttriubteCollider.gameObject.AddComponent <MapKeyEventSpeaker>(); tSpeaker.mBehaviour = tCharacter; tSpeaker.mSpeakDefault = aData.mSpeakDefault; tSpeaker.mSpeakFromUp = aData.mSpeakFromUp; tSpeaker.mSpeakFromDown = aData.mSpeakFromDown; tSpeaker.mSpeakFromLeft = aData.mSpeakFromLeft; tSpeaker.mSpeakFromRight = aData.mSpeakFromRight; } return(tCharacter); }
public void TestObjectPoolBorrow() { var originalGameObj = new GameObject(); originalGameObj.AddComponent <MyBehaviour>(); var objPool = new AltoObjectPool <MyBehaviour>(originalGameObj, 3); Assert.That(objPool.RemainCount, Is.EqualTo(3)); MyBehaviour obj1 = objPool.Get(); Assert.That(obj1.gameObject.activeSelf, Is.True); Assert.That(objPool.RemainCount, Is.EqualTo(2)); MyBehaviour obj2 = objPool.Get(); Assert.That(objPool.RemainCount, Is.EqualTo(1)); MyBehaviour obj3 = objPool.Get(); Assert.That(objPool.RemainCount, Is.EqualTo(0)); MyBehaviour obj4 = objPool.Get(); Assert.That(objPool.RemainCount, Is.EqualTo(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); }
private void createBeatObject(bool aTriplet = false) { if (mBeatObject != null) { mBeatObject.delete(); } mBeatObject = MyBehaviour.createObjectFromPrefab <MyBehaviour>("score/" + (aTriplet ? "beatTriplet" : "beat")); mBeatObject.transform.parent = this.gameObject.transform; mBeatObject.transform.localPosition = new Vector3(0, 0, 0); mBeatObject.transform.localScale = new Vector3(1, 1, 1); //配列初期化 if (aTriplet) { mNotes = new Note[3]; mLyricses = new LyricsBubble[3]; mBpms = new ChangeBpmObject[3]; } else { mNotes = new Note[4]; mLyricses = new LyricsBubble[4]; mBpms = new ChangeBpmObject[4]; } //behaviour取得 mNotePositions = mBeatObject.findChild("notes").GetComponent <MyBehaviour>().GetComponentsInChildrenWithoutSelf <Transform>(); mLyricsPositions = mBeatObject.findChild("lyricses").GetComponent <MyBehaviour>().GetComponentsInChildrenWithoutSelf <Transform>(); mBpmPositions = mBeatObject.findChild("bpms").GetComponent <MyBehaviour>().GetComponentsInChildrenWithoutSelf <Transform>(); sendTimeToColliders(); }
public void checkAllOpen() { if (!(mDice1.mIsOpen & mDice2.mIsOpen & mDice3.mIsOpen)) { return; } MyBehaviour.setTimeoutToIns(1, () => { mArg.get <Action <int> >("opened")(getTotalNumber()); }); }
void Awake() { mMassList = new List <GameMass>(); mMassContainer = this.createChild <MyBehaviour>("massContainer"); mRouteContainer = this.createChild <MyBehaviour>("routeContainer"); mComaContainer = this.createChild <MyBehaviour>("comaContainer"); mWallContainer = this.createChild <MyBehaviour>("wallContainer"); }
/// <summary> /// エンカウント /// </summary> /// <param name="aMapName">エンカウトしたマップのマップ名</param> /// <param name="aEncountKey">エンカウントKey</param> /// <param name="onEnd">戦闘終了時コールバック</param> public void onEncount(string aMapName, string aEncountKey, Action <BattleEventResult> aOnEnd) { Debug.Log("encount:(" + aMapName + "," + aEncountKey + ")"); MyBehaviour.setTimeoutToIns(3f, () => { Debug.Log("end encount battle"); aOnEnd(BattleEventResult.win); }); }
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); }
private void Awake() { //テキスト表示領域生成 mBoard = MyBehaviour.create <MyTextBoard>(); mBoard.transform.SetParent(this.transform, false); mBoard.name = this.name + ":TextBoard"; mBoard.mFont = mFont; adjustBoardSize(); }
//消滅 protected void hitAndDelete(MyBehaviour aNoteObject) { //透明度 aNoteObject.opacityBy(-1, 0.4f, () => { aNoteObject.delete(); }); //大きさ aNoteObject.scaleBy(new Vector3(0.3f, 0.5f, 0), 0.2f, null); }
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); }
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); } }
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); }
private void Awake() { if (mWriting != null) { mWriting.name = "deletedWriting"; mWriting.deleteOnEditMode(); } mWriting = null; regenerate(); }
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); } }
public void TriggerEnterWillBeCalledOnMonoBehavioursOnTheGameObject() { GameObject go = new GameObject(); MyBehaviour beh = new MyBehaviour(); go.AddComponent(beh); go.OnTriggerEnter(null); Assert.That(beh.triggerEnterCalled, Is.True); }
public void CollisionStayWillBeCalledOnMonoBehavioursOnTheGameObject() { GameObject go = new GameObject(); MyBehaviour beh = new MyBehaviour(); go.AddComponent(beh); go.OnCollisionStay(null); Assert.That(beh.collisionStayCalled, Is.True); }
private void OnValidate() { mWriting = this.findChild <MyBehaviour>("writing"); if (mWriting != null) { mWriting.name = "deletedWriting"; mWriting.deleteOnEditMode(); } mWriting = null; regenerate(); }