コード例 #1
0
ファイル: AiController.cs プロジェクト: tTomonori/animalKing
    public override void freeLand(PlayerStatus aMyself, GameElementData aElement, Action <LandMasStatus> aAnser)
    {
        List <LandMasStatus> tOccupiedList = aElement.getAllOccupiedLand(aMyself);

        LandMasStatus[] tOccupied = tOccupiedList.ToArray();
        //略奪コストが最も安い土地を解放
        Array.Sort(tOccupied, (x, y) => { return(x.mLootedCost - y.mLootedCost); });
        aAnser(tOccupied[0]);
    }
コード例 #2
0
    public override void selectOccupyLand(PlayerStatus aMyself, GameElementData aElement, Action <LandMasStatus> aAnser)
    {
        aElement.mTable.showOneSelectForm("占領する土地を\n選択してください", "占領しない");
        LandMasStatus tSelected = null;

        //マスタップ監視
        Subject.addObserver(new Observer("playerControllerTouchMas", (aMessage) => {
            if (aMessage.name != "touchMas")
            {
                return;                             //監視外メッセージ
            }
            MasStatus tMas = aElement.mMasStatus[aMessage.parameters.get <int>("number")];
            if (!(tMas is LandMasStatus))
            {
                return;                          //土地のマス以外
            }
            LandMasStatus tLand = (LandMasStatus)tMas;
            if (tLand.mOwnerNumber >= 0)
            {
                return;                         //占領済マス
            }
            if (aMyself.mFood < tLand.mOccupyCost)
            {
                return;                                   //所持食糧を超えるコストのマス
            }
            tSelected = tLand;
            aElement.mTable.hideMessage();
            aElement.mTable.hideOneSelectForm();
            aElement.mTable.question(tSelected.mName + "を占領しますか?\n食糧-" + tLand.mOccupyCost);
        }));
        //はい,いいえ,占領しない選択監視
        Subject.addObserver(new Observer("playerControllerTableQuestion", (aMessage) => {
            if (aMessage.name == "yes")
            {
                Subject.removeObserver("playerControllerTouchMas");
                Subject.removeObserver("playerControllerTableQuestion");
                aElement.mTable.hideQuestionForm();
                aAnser(tSelected);
            }
            else if (aMessage.name == "no")
            {
                aElement.mTable.hideQuestionForm();
                tSelected = null;
                aElement.mTable.showOneSelectForm("占領する土地を\n選択してください", "占領しない");
            }
            else if (aMessage.name == "oneSelect")
            {
                Subject.removeObserver("playerControllerTouchMas");
                Subject.removeObserver("playerControllerTableQuestion");
                aElement.mTable.hideOneSelectForm();
                aAnser(null);
            }
        }));
    }
コード例 #3
0
//		public bool RequesetRV (ICocoLockableStateControl stateControl)
//		{
//			if (!RVReady) {
//				return false;
//			}
//			if (m_RequestingStateControl != null) {
//				return false;
//			}

//			m_RequestingStateControl = stateControl;
//			GameElementData adData = new GameElementData (GameElementType.State, stateControl.GetRVKey (), 0);
//			requestRewardAdsSignal.Dispatch (adData);
//			return true;
//		}

        protected void RewardResultEvent(bool result, GameElementData pData)
        {
            m_RVResultFrameCount = Time.frameCount;

//			if (m_RequestingStateControl != null) {
//				if (result && pData.key == m_RequestingStateControl.GetRVKey ()) {
//					m_RequestingStateControl.OnRvReleased ();
//				}
//				m_RequestingStateControl = null;
//			}

            updateRvStatusSignal.Dispatch();
        }
コード例 #4
0
ファイル: AiController.cs プロジェクト: tTomonori/animalKing
    public override void selectOccupyLand(PlayerStatus aMyself, GameElementData aElement, Action <LandMasStatus> aAnser)
    {
        List <LandMasStatus> tFreeList = aElement.getAllFreeLand();

        LandMasStatus[] tFree = tFreeList.ToArray();
        //最も価値が安い土地を占領
        Array.Sort(tFree, (x, y) => { return(x.mOccupyCost - y.mOccupyCost); });
        foreach (LandMasStatus tLand in tFree)
        {
            if (tLand.mOccupyCost <= aMyself.mFood)
            {
                aAnser(tLand);
                return;
            }
        }
        aAnser(null);
        return;
    }
コード例 #5
0
    public static void DrawListOfGameElemetData(string caption, List <GameElementData> list, ref bool dirty)
    {
        if (list == null)
        {
            return;
        }

        contentColor    = GUI.contentColor;
        backgroundColor = GUI.backgroundColor;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField(caption, GUILayout.Width(100));
        GUI.backgroundColor = greenColor;
        if (GUILayout.Button("Add", GUILayout.Width(60)))
        {
            GameElementData newData = new GameElementData(GameElementType.Item, "Key " + list.Count, 1);
            list.Add(newData);
            dirty = true;
        }
        GUI.backgroundColor = backgroundColor;
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(30);
        EditorGUILayout.BeginVertical();
        GameElementData removedElement = null;

        foreach (var element in list)
        {
            if (DrawSingleGameElementData(element, ref dirty))
            {
                removedElement = element;
            }
        }
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();

        if (null != removedElement)
        {
            list.Remove(removedElement);
            dirty = true;
        }
    }
コード例 #6
0
    public override void freeLand(PlayerStatus aMyself, GameElementData aElement, Action <LandMasStatus> aAnser)
    {
        aElement.mTable.showMessage("解放する土地を\n選択してください");
        LandMasStatus tSelected = null;

        //マスタップ監視
        Subject.addObserver(new Observer("playerControllerTouchMas", (aMessage) => {
            if (aMessage.name != "touchMas")
            {
                return;                             //監視外メッセージ
            }
            MasStatus tMas = aElement.mMasStatus[aMessage.parameters.get <int>("number")];
            if (!(tMas is LandMasStatus))
            {
                return;                          //土地のマス以外
            }
            LandMasStatus tLand = (LandMasStatus)tMas;
            if (tLand.mOwnerNumber != aMyself.mPlayerNumber)
            {
                return;                                             //自分以外の土地
            }
            tSelected = tLand;
            aElement.mTable.hideMessage();
            aElement.mTable.question(tSelected.mName + "を解放しますか?\n食糧+" + tLand.mFreeCost);
        }));
        //はい,いいえ選択監視
        Subject.addObserver(new Observer("playerControllerTableQuestion", (aMessage) => {
            if (aMessage.name == "yes")
            {
                Subject.removeObserver("playerControllerTouchMas");
                Subject.removeObserver("playerControllerTableQuestion");
                aElement.mTable.hideQuestionForm();
                aAnser(tSelected);
            }
            else if (aMessage.name == "no")
            {
                aElement.mTable.hideQuestionForm();
                tSelected = null;
                aElement.mTable.showMessage("解放する土地を\n選択してください");
            }
        }));
    }
コード例 #7
0
 public override void expandLand(PlayerStatus aMyself, LandMasStatus aLand, GameElementData aElement, Action <bool> aAnser)
 {
     Subject.addObserver(new Observer("playerController", (aMessage) => {
         if (aMessage.name == "yes")
         {
             aAnser(true);
         }
         else if (aMessage.name == "no")
         {
             aAnser(false);
         }
         else
         {
             return;
         }
         Subject.removeObserver("playerController");
         aElement.mTable.hideQuestionForm();
     }));
     aElement.mTable.question("食糧" + aLand.mExpansionCost + "で拡大しますか?");
 }
コード例 #8
0
ファイル: GameMain.cs プロジェクト: tTomonori/animalKing
    // Start is called before the first frame update
    void Start()
    {
        Arg tArg = MySceneManager.getArg("game");

        MySoundPlayer.playBgm("Morning_2", MySoundPlayer.LoopType.normalConnect, 0.7f);

        mElement = new GameElementData();

        mElement.mInitData         = tArg.get <GameInitData>("data");
        mElement.mStageData        = new StageData(mElement.mInitData.mStagePath);
        LandMasStatus.mLootingRate = mElement.mInitData.mLooting / 100.0f;

        initPlace();
        initStatus();
        //piece
        mElement.mPlayerPieces = GamePlacer.placePiece(mElement.mPlayerStatus, mElement.mMasDisplay[0].position2D);

        mMaster          = MyBehaviour.create <GameMaster>();
        mMaster.name     = "GameMaster";
        mMaster.mElement = mElement;
        mMaster.mMain    = this;

        mMaster.start();
    }
コード例 #9
0
    /// <summary>
    /// /Draws the single game element data.*/
    /// </summary>
    /// <returns><c>true</c>, if single game element data was marked for removal, <c>false</c> otherwise.</returns>
    /// <param name="element">Element.</param>
    /// <param name="dirty">Dirty.</param>
    public static bool DrawSingleGameElementData(GameElementData element, ref bool dirty, bool enableDelete = true)
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Type:", GUILayout.Width(100));
        GameElementType oldType = element.type;

        element.type = (GameElementType)EditorGUILayout.EnumPopup(element.type, GUILayout.Width(150));
        if (element.type != oldType)
        {
            dirty = true;
        }
        bool removed = false;

        if (enableDelete)
        {
            GUI.backgroundColor = redColor;
            if (GUILayout.Button("Delete this entry", GUILayout.Width(100)))
            {
                removed = true;
            }
            GUI.backgroundColor = backgroundColor;
        }
        EditorGUILayout.EndHorizontal();

        if (element.type == GameElementType.Item)
        {
            if (allItems == null)
            {
                EditorGUILayout.HelpBox("Items are not loaded properly.", MessageType.Error);
            }
            else if (allItems.Count == 0)
            {
                EditorGUILayout.HelpBox("There are no Items. Use Item Editor to add some.", MessageType.Info);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Item:", GUILayout.Width(100));
                int oldIntValue = IndexFromName(element.key, itemConfigNames);
                int newIntValue = EditorGUILayout.Popup(oldIntValue, itemConfigNames, GUILayout.Width(150));
                if (oldIntValue != newIntValue)
                {
                    element.key = itemConfigNames[newIntValue];
                    dirty       = true;
                }
                EditorGUILayout.EndHorizontal();
            }
        }
        else if (element.type == GameElementType.State)
        {
            if (allCollectibles == null)
            {
                EditorGUILayout.HelpBox("Collectibles are not loaded properly.", MessageType.Error);
            }
            else if (allCollectibles.Count == 0)
            {
                EditorGUILayout.HelpBox("There are no Collectibles. Use Collectibles Editor to add some.", MessageType.Info);
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Collectible:", GUILayout.Width(100));
                int oldIntValue = IndexFromName(element.key, collectibleConfigNames);
                int newIntValue = EditorGUILayout.Popup(oldIntValue, collectibleConfigNames, GUILayout.Width(150));
                if (oldIntValue != newIntValue)
                {
                    element.key = collectibleConfigNames[newIntValue];
                    dirty       = true;
                }
                EditorGUILayout.EndHorizontal();
            }
        }
        else if (element.type == GameElementType.Currency)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Key:", GUILayout.Width(100));
            string oldStringValue = element.key;
            element.key = EditorGUILayout.TextField(element.key, GUILayout.Width(150));
            if (element.key != oldStringValue)
            {
                dirty = true;
            }
            EditorGUILayout.EndHorizontal();
        }

        //		public string value;
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField("Value:", GUILayout.Width(100));
        int oldValue = element.value;

        element.value = EditorGUILayout.IntField(element.value, GUILayout.Width(150));
        if (element.value != oldValue)
        {
            dirty = true;
        }
        EditorGUILayout.EndHorizontal();
        return(removed);
    }
コード例 #10
0
ファイル: AiController.cs プロジェクト: tTomonori/animalKing
 public override void expandLand(PlayerStatus aMyself, LandMasStatus aLand, GameElementData aElement, Action <bool> aAnser)
 {
     aAnser(true);
 }
コード例 #11
0
 //どの土地を占領するか
 abstract public void selectOccupyLand(PlayerStatus aMyself, GameElementData aElement, Action <LandMasStatus> aAnser);
コード例 #12
0
 //土地を拡大するか
 abstract public void expandLand(PlayerStatus aMyself, LandMasStatus aLand, GameElementData aElement, Action <bool> aAnser);