///<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);
    }
Exemple #2
0
    // Start is called before the first frame update
    void Start()
    {
        //pad
        mPad = GameObject.Find("pad").GetComponent <MyPad>();
        //map
        MyMap.mMapResourcesDirectory = "mymap";
        mMap = GameObject.Find("map").GetComponent <MyMap>();
        //delegate
        mDelegate      = new TestEventDelegate();
        mMap.mDelegate = mDelegate;
        //player
        MapFileData.Character tPlayerData = new MapFileData.Character(new Arg());
        tPlayerData.mName      = "player";
        tPlayerData.mMoveSpeed = 2.5f;
        tPlayerData.mPath      = "player/player";
        tPlayerData.mAiString  = "<player>";
        mMap.mPlayerData       = tPlayerData;

        mMap.mFlag = MyFlag.load("Assets/resources/save/flagSaveData.json");
        //mMap.load("rpMap");
        mMap.loadSaveData("Assets/resources/save/mapSaveData.json");

        //contoroller
        mController      = new MyMapController();
        mMap.mController = mController;
    }
    ///<summary>キャラクターを生成してworldに追加</summary>
    static private MapCharacter buildCharacter(MapFileData.Character aData)
    {
        //生成フラグ確認
        if (!flagCreate(aData))
        {
            return(null);
        }

        MapCharacter tCharacter = createCharacter(aData);

        tCharacter.mFileData = aData;
        tCharacter.transform.SetParent(mWorld.mCharacterContainer.transform, false);
        tCharacter.mMapPosition = new MapPosition(aData.mPosition);
        tCharacter.changeLayer(MyMap.mStratumLayerNum[Mathf.FloorToInt(aData.mY)]);
        mWorld.mCharacters.Add(tCharacter);
        return(tCharacter);
    }
 /// <summary>
 /// キャラクターを生成して追加
 /// </summary>
 /// <param name="aCharacterData">追加するキャラクターのデータ</param>
 /// <param name="aWorld">キャラクターを追加するworld</param>
 static public void addCharacter(MapFileData.Character aCharacterData, MapWorld aWorld)
 {
     mWorld = aWorld;
     buildCharacter(aCharacterData).placed();
     mWorld = null;
 }