예제 #1
0
 //When button on upgrade shop is clicked, save the type of the creatures stored in the button
 //make location button interactable(clickable) for player to put decided creature to the position they want
 void TargetCreature(Vector2Int type)
 {
     changingInfo = type;
     if (PublicLevel.unlockType[type.x, type.y] == true)
     {
         for (int i = 0; i < PublicLevel.usingCreatureNum; i++)
         {
             locationButton[i].interactable = true;
         }
     }
     else
     {
         for (int i = 0; i < PublicLevel.usingCreatureNum; i++)
         {
             locationButton[i].interactable = false;
         }
         unlockPopup.SetActive(true);
         int price = PublicLevel.friendlyPrefab[type.x, type.y].GetComponent <DefaultCreature>().GetUnlockCost();
         if (PublicLevel.GetCorn() < price)
         {
             unlockPopup.transform.GetChild(1).GetComponent <Button>().interactable   = false;
             unlockPopup.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = "Unlock\n (Not enough corns)";
         }
         else
         {
             unlockPopup.transform.GetChild(1).GetComponent <Button>().interactable   = true;
             unlockPopup.transform.GetChild(1).GetChild(0).GetComponent <Text>().text = "Unlock\n (" + price + " corn )";
         }
     }
 }
예제 #2
0
    //Save parameters stored in the button to the PublicLevel and load scene
    public override void InitLevel()
    {
        StartCoroutine(ServerControl.OpenStream(3.0f));
        PublicLevel.SetLevel(hostileType, manaAmount, manaRegenTime, creatureSpawnTime, stageLevel, false, null);

        WaitForServer(3.0f);
    }
예제 #3
0
    // summon friendly and hostile base
    public void SummonBoss()
    {
        /*for (int i = 0; i < 3; i++)
         * {
         *  //create three invisible creatures to take all lane's damage
         *  SummonCreature(i, GameControl.Sides.Hostile, 0);
         * }*/

        for (int i = 0; i < PublicLevel.usingLaneNum; ++i)
        {
            //spawn an actor through instantiate
            GameObject      newObject;
            DefaultCreature newCreature;;
            newObject = Instantiate <GameObject>(PublicLevel.GetBossPrefab());

            // pass control instances to each of the creatures
            newCreature = newObject.GetComponent <DefaultCreature>();
            newCreature.SetGameControl(gameControl);
            newCreature.SetCombatControl(combatControl);

            // set start and end coordinates for spawning creature
            startCoord[i] -= new Vector3(0, 0, layerOffset);
            endCoord[i]   -= new Vector3(0, 0, layerOffset);
            newCreature.SetCreature(endCoord[i], startCoord[i], 0, i, GameControl.Sides.Hostile);

            newObject.tag = "Boss";

            // push creature into the list(side, lane) in combatControl
            combatControl.PushCreature(i, GameControl.Sides.Hostile, newCreature);
        }
    }
예제 #4
0
 //opposite of LoadUpgrade. Activate stageMap and Deactivate upgradeShop. Save data that have been changed during upgradeShop
 public void LoadMap()
 {
     cornText.text = PublicLevel.GetCorn().ToString();
     gameData.SaveGameData();
     stageMap.SetActive(true);
     upgradeShop.SetActive(false);
 }
예제 #5
0
 // update PublicLevel to save win on exitting game
 public override void GameOver(bool isWin)
 {
     if (isWin)
     {
         PublicLevel.SetPlayerWin(PublicLevel.GetPlayerWin() + 1);
     }
     base.GameOver(true);
 }
예제 #6
0
    public void UnlockCreature()
    {
        int cost = PublicLevel.friendlyPrefab[changingInfo.x, changingInfo.y].GetComponent <DefaultCreature>().GetUnlockCost();

        PublicLevel.SetCorn(PublicLevel.GetCorn() - cost);
        PublicLevel.unlockType[changingInfo.x, changingInfo.y] = true;
        unlockPopup.SetActive(false);
    }
예제 #7
0
 // Use this for initialization
 void Start()
 {
     serverStream = PublicLevel.GetServerStream();
     // Start TcpServer background thread
     tcpListenerThread = new Thread(new ThreadStart(ListenForIncommingRequests));
     tcpListenerThread.IsBackground = true;
     tcpListenerThread.Start();
 }
예제 #8
0
    // create and save a GameDataForm
    public void SaveGameData()
    {
        // find GameData in the scene
        GameDataForm currentGameData = GameObject.Find("GameDataControl").GetComponent <GameData>();

        // set GameData variables according to PublicLevel
        currentGameData.SetGameData(PublicLevel.GetPlayerLevel(), PublicLevel.GetPlayerWin(), PublicLevel.GetCorn(), PublicLevel.friendlyType, PublicLevel.unlockType);
        // save current GameData
        SaveGame(currentGameData, GetFileName());
    }
예제 #9
0
    // initialize prefab list and its mana costs according to PublicLevel
    void InitStage()
    {
        friendlyCreatureList = new GameObject[PublicLevel.friendlyTypeCreatureNum];
        hostileCreatureList  = new GameObject[PublicLevel.friendlyTypeCreatureNum];

        friendlyCreatureManaCost = new int[PublicLevel.friendlyTypeCreatureNum];
        hostileCreatureManaCost  = new int[PublicLevel.friendlyTypeCreatureNum];

        PublicLevel.PlayerStageSetting(friendlyCreatureList, hostileCreatureList);

        for (int i = 0; i < PublicLevel.friendlyTypeCreatureNum; i++)
        {
            friendlyCreatureManaCost[i] = friendlyCreatureList[i].GetComponent <DefaultCreature>().GetManaCost();
        }
    }
예제 #10
0
    //Change friendlyCreatureList and image of the button to the saved creature/upgrade type at TargetCreature function.
    void ChangeCreature(int location)
    {
        PublicLevel.UpdateFriendlyList(location, changingInfo);


        upgradeShop.transform.GetChild(2 + location).GetChild(0).GetComponent <Image>().sprite = PublicLevel.friendlyImageList[location];

        //player use 10 corns per changing upgrade mode will be fixed soon.
        cornText.text = PublicLevel.GetCorn().ToString();

        //make location button no longer interactable
        for (int i = 0; i < PublicLevel.usingCreatureNum; i++)
        {
            locationButton[i].interactable = false;
        }
    }
예제 #11
0
    // Initialization of variables and data structures in AIPlayer
    void InitAI()
    {
        currentMana = 0;
        // initialize mana variables according to PublicLevel
        this.manaAmount        = PublicLevel.GetManaAmount();
        this.manaRegenTime     = PublicLevel.GetManaRegenTime();
        this.creatureSpawnTime = PublicLevel.GetCreatureSpawnTime();
        hostileCreatureList    = new GameObject[PublicLevel.hostileTypeCreatureNum];
        PublicLevel.GetHostileCreatureList(hostileCreatureList);

        // deciding how much creatures will be spawned, and its composition
        SetCreatureArray();
        minimumCost = GetMinimumCost();
        SetCreatureRatio();
        SetCreatureFlag();
    }
예제 #12
0
    public static IEnumerator OpenStream(float waitTime)
    {
        yield return(new WaitForSeconds(waitTime));

        TcpClient _socketConnection;

        try
        {
            _socketConnection = new TcpClient(ServerControlForm.GetUrl(), ServerControlForm.GetPort());
            PublicLevel.SetServerStream(_socketConnection.GetStream());
        }
        catch (SocketException socketException)
        {
            Debug.Log("SocketException " + socketException.ToString());
            StageButtonMultiplayer.NetworkErrorPanelactive();
        }
    }
예제 #13
0
    //called from PlayerBase when one of the player died
    public virtual void GameOver(bool isWin)
    {
        // if player destroyed hostile base
        if (isWin && gameOverFlag == false)
        {
            // if incoming boss remains
            if (PublicLevel.GetIsBoss())
            {
                //spawn boss
                spawnControl.SummonBoss();
                PublicLevel.SetIsBoss(false);
            }
            else
            {
                PublicLevel.SetPlayerLevel(PublicLevel.GetStageLevel() + 1);
                spawnControl.DeadAllHostileCreature();
                aiplayer.AIplayerStop();
                winPanel.SetActive(true);
                winPanel.transform.GetChild(0).GetComponent <Text>().text = "Your level is " + PublicLevel.GetPlayerLevel().ToString();
                Debug.Log("player win!");
            }

            for (int i = 0; i < PublicLevel.usingLaneNum; ++i)
            {
                GameObject[] laneObjects = GameObject.FindGameObjectsWithTag("Lane" + i.ToString());
                foreach (GameObject laneObject in laneObjects)
                {
                    if (laneObject.name == "creature0_0Prefab(Clone)" && laneObject.GetComponent <DefaultCreature>().GetSide() == GameControl.Sides.Hostile)
                    {
                        laneObject.GetComponent <DefaultCreature>().Dead();
                    }
                }
            }
            return;
        }
        // if player's base was destroyed
        else if (!isWin && gameOverFlag)
        {
            losePanel.SetActive(true);
        }
        gameOverFlag = true;
        aiplayer.AIplayerStop();
    }
예제 #14
0
    public static IEnumerator ListenForHostileCreatureList(float waitTime)
    {
        yield return(new WaitForSeconds(waitTime));

        buffer = new byte[bufferSize];
        try
        {
            Vector2Int[] _hostileType = new Vector2Int[PublicLevel.usingCreatureNum];
            PublicLevel.GetServerStream().BeginRead(buffer, 0, bufferSize, OnReceive, null);

            creatureReceiveSuccess = true;
            // load after creaturelist receive is complete
            LoadingSceneManager.LoadScene("DefaultIngameCopy");
        }
        catch (Exception listSendException)
        {
            Debug.Log("ListSendException " + listSendException.ToString());
            StageButtonMultiplayer.NetworkErrorPanelactive();
        }
        StageButtonMultiplayer.SetCreatureFlag(true);
        StageButtonMultiplayer.NetworkWaitPanelInactive();
    }
예제 #15
0
    public static bool SendCreatureList()
    {
        buffer = new byte[bufferSize];
        try
        {
            // create a socket for streaming data

            string       serverMessage = "";
            Vector2Int[] friendlyType  = PublicLevel.GetFriendlyType();
            for (int i = 0; i < PublicLevel.usingCreatureNum; ++i)
            {
                serverMessage = serverMessage + friendlyType[i].x.ToString() + ',' + friendlyType[i].y.ToString() + " ";
            }
            buffer = Encoding.ASCII.GetBytes(serverMessage);
            PublicLevel.GetServerStream().Write(buffer, 0, buffer.Length);
            ClearBuffer(buffer);
        }
        catch (SocketException socketException)
        {
            Debug.Log("SocketException " + socketException.ToString());
            return(false);
        }
        return(true);
    }
예제 #16
0
    //called when upgradeShop open button is clicked. activate upgradeShop UI and deactivate stageMap UI. Image setup for button
    public void LoadUpgrade()
    {
        upgradeShop.SetActive(true);
        cornText.text = PublicLevel.GetCorn().ToString();
        //Changes images of button to the UpgradeOption buttons based on friendlyImage[,]
        for (int i = 0; i < PublicLevel.friendlyTypeCreatureNum; i++)
        {
            for (int k = 0; k < PublicLevel.friendlyTypeUpgradeNum; k++)
            {
                listObject = upgradeShop.transform.GetChild(7 + i).gameObject;
                listObject.GetComponent <Image>().sprite = PublicLevel.friendlyImage[i, k];
            }
        }

        //Changes images of location button based on friendlyImageList[]
        for (int i = 0; i < PublicLevel.usingCreatureNum; i++)
        {
            listObject = upgradeShop.transform.GetChild(2 + i).GetChild(0).gameObject;
            listObject.GetComponent <Image>().sprite = PublicLevel.friendlyImageList[i];
            locationButton[i].interactable           = false;
        }

        stageMap.SetActive(false);
    }
예제 #17
0
 //Save parameters stored in the button to the PublicLevel and load scene
 public virtual void InitLevel()
 {
     PublicLevel.SetLevel(hostileType, manaAmount, manaRegenTime, creatureSpawnTime, stageLevel, isBoss, bossPrefab);
     LoadingSceneManager.LoadScene("DefaultIngame");
 }
예제 #18
0
        public async Task OverviewAsync(CommandContext ctx)
        {
            using var context = new DiscordContext();

            DiscordEmbedBuilder builder = new DiscordEmbedBuilder()
            {
                Title = "These are all of your settings"
            };

            var settings = UserSetting.GetAllSettings(ctx.Message.Author.Id, context).ToDictionary(setting => (UserSetting.SettingID)setting.SettingId);
            var items    = await WheelItemExtension.GetUserItemsAsync(ctx.Message.Author.Id, context);

            AnalLevel analLevel = AnalLevel.None;

            if (settings.ContainsKey(SettingID.AnalLevel))
            {
                analLevel = settings[SettingID.AnalLevel].GetValue <AnalLevel>();
            }

            UserSetting.WheelDifficultyPreference wheelDifficulty = UserSetting.WheelDifficultyPreference.Default;
            if (settings.ContainsKey(SettingID.WheelDifficulty))
            {
                wheelDifficulty = settings[SettingID.WheelDifficulty].GetValue <UserSetting.WheelDifficultyPreference>();
            }

            UserSetting.WheelTaskPreferenceSetting wheelTaskPreference = UserSetting.WheelTaskPreferenceSetting.Default;
            if (settings.ContainsKey(SettingID.WheelTaskPreference))
            {
                wheelTaskPreference = settings[SettingID.WheelTaskPreference].GetValue <UserSetting.WheelTaskPreferenceSetting>();
            }

            BondageLevel bondageLevel = BondageLevel.None;

            if (settings.ContainsKey(SettingID.BondageLevel))
            {
                bondageLevel = settings[SettingID.BondageLevel].GetValue <BondageLevel>();
            }

            CBTLevel cbtLevel = CBTLevel.None;

            if (settings.ContainsKey(SettingID.CBTLevel))
            {
                cbtLevel = settings[SettingID.CBTLevel].GetValue <CBTLevel>();
            }

            DungeonDifficulty dungeonDifficulty = DungeonDifficulty.Normal;

            if (settings.ContainsKey(SettingID.DungeonDifficulty))
            {
                dungeonDifficulty = settings[SettingID.DungeonDifficulty].GetValue <DungeonDifficulty>();
            }

            //PeeLevel peeLevel = PeeLevel.None;
            //if (settings.ContainsKey(SettingID.PeeLevel))
            //{
            //    peeLevel = settings[SettingID.PeeLevel].GetValue<PeeLevel>();
            //}

            SissyLevel sissyLevel = SissyLevel.None;

            if (settings.ContainsKey(SettingID.SissyLevel))
            {
                sissyLevel = settings[SettingID.SissyLevel].GetValue <SissyLevel>();
            }

            //DegrationLevel degrationLevel = DegrationLevel.None;
            //if (settings.ContainsKey(SettingID.DegrationLevel))
            //{
            //    degrationLevel = settings[SettingID.DegrationLevel].GetValue<DegrationLevel>();
            //}

            PublicLevel publicLevel = PublicLevel.None;

            if (settings.ContainsKey(SettingID.PublicLevel))
            {
                publicLevel = settings[SettingID.PublicLevel].GetValue <PublicLevel>();
            }

            Gender gender = Gender.None;

            if (settings.ContainsKey(SettingID.Gender))
            {
                gender = settings[SettingID.Gender].GetValue <Gender>();
            }

            foreach (SettingID possibleSetting in Enum.GetValues(typeof(SettingID)))
            {
                Enum setting = null;

                switch (possibleSetting)
                {
                case SettingID.AnalLevel:
                    setting = analLevel;
                    break;

                case SettingID.BanType:
                    break;

                case SettingID.WheelDifficulty:
                    setting = wheelDifficulty;
                    break;

                case SettingID.WheelTaskPreference:
                    setting = wheelTaskPreference;
                    break;

                case SettingID.BondageLevel:
                    setting = bondageLevel;
                    break;

                case SettingID.Toys:
                    break;

                case SettingID.CBTLevel:
                    setting = cbtLevel;
                    break;

                case SettingID.DungeonDifficulty:
                    break;

                case SettingID.PeeLevel:
                    break;

                case SettingID.SissyLevel:
                    setting = sissyLevel;
                    break;

                case SettingID.DegrationLevel:
                    break;

                case SettingID.PublicLevel:
                    setting = publicLevel;
                    break;

                case SettingID.BanEnd:
                    break;

                case SettingID.Gender:
                    setting = gender;
                    break;
                }

                if (setting == null)
                {
                    continue;
                }

                var name  = possibleSetting.ToFormattedText();
                var value = $"{setting.ToFormattedText()} ({Convert.ToInt32(setting)})";

                builder.AddField(name, value, true);
            }

            await ctx.RespondAsync(embed : builder.Build());

            if (items.Any())
            {
                builder = new DiscordEmbedBuilder()
                {
                    Title = "Your Items"
                };

                foreach (var item in items.OrderBy(it => it.ItemId))
                {
                    var cItem = (WheelItemExtension.Item)item.ItemId;
                    builder.AddField(cItem.ToFormattedText(), item.ItemId.ToString());
                }

                await ctx.RespondAsync(embed : builder.Build());
            }
        }
예제 #19
0
    private void Start()
    {
        //make buttons to call TargetCreature function which sends upgradeoption[temp] as a parameter.
        for (int i = 0; i < PublicLevel.friendlyTypeCreatureNum; i++)
        {
            upgradeButton[i] = GameObject.Find("UpgradeButton" + (i + 1)).GetComponent <Button>();
            int temp = i; //used temp since just using i makes every buttons to send last i value as a parameter
            upgradeButton[i].GetComponent <Button>().onClick.AddListener(delegate { TargetCreature(upgradeOption[temp]); });
        }

        //make buttons toi call ChangeCreature fucntion
        for (int i = 0; i < PublicLevel.usingCreatureNum; i++)
        {
            locationButton[i] = GameObject.Find("Location" + (i + 1)).GetComponent <Button>();
            int temp = i;
            locationButton[temp].onClick.AddListener(delegate { ChangeCreature(temp); });
        }

        unlockPopup.SetActive(false);
        //UI upgradShop is not shown until upgradeShop is active
        upgradeShop.SetActive(false);

        //Try to find GameDataControl
        gameDataControl = GameObject.Find("GameDataControl");

        //if no gameDataControl exists, instantiate one new gameDataControl
        if (gameDataControl == null)
        {
            gameDataControl      = Instantiate(new GameObject(), transform.position, Quaternion.identity);
            gameDataControl.name = "GameDataControl";
            gameData             = gameDataControl.AddComponent <GameData>();

            loadedData = gameData.LoadGameData();


            //load when StageSelect scene was first loaded. If there's no loadedData, make a default setting for player - level, win, creature type using.
            if (loadedData == null)
            {
                PublicLevel.SetPlayerLevel(1);
                PublicLevel.SetPlayerWin(0);
                PublicLevel.SetCorn(0);
                for (int i = 1; i < 6; i++)
                {
                    PublicLevel.unlockType[i, 0] = true;
                }
                for (int i = 0; i < PublicLevel.friendlyTypeCreatureNum; i++)
                {
                    PublicLevel.friendlyType[i] = new Vector2Int(i, 0);
                }
            }
            else
            {
                PublicLevel.SetPlayerLevel(loadedData.GetPlayerLevel());
                PublicLevel.SetPlayerWin(loadedData.GetPlayerWin());
                PublicLevel.SetCorn(loadedData.GetCorn());

                for (int i = 0; i < PublicLevel.usingCreatureNum; i++)
                {
                    PublicLevel.friendlyType[i] = new Vector2Int(loadedData.GetFriendlyType()[i].x, loadedData.GetFriendlyType()[i].y);
                }

                for (int i = 0; i < PublicLevel.friendlyTypeCreatureNum; i++)
                {
                    for (int k = 0; k < PublicLevel.friendlyTypeUpgradeNum; k++)
                    {
                        PublicLevel.unlockType[i, k] = loadedData.GetUnlockType()[i, k];
                    }
                }
            }

            //fill frienldyCreatureList based on loaded/default friendlyType
            for (int i = 0; i < PublicLevel.friendlyTypeCreatureNum; i++)
            {
                PublicLevel.friendlyCreatureList[i] = PublicLevel.friendlyPrefab[PublicLevel.friendlyType[i].x, PublicLevel.friendlyType[i].y];

                PublicLevel.friendlyImageList[i] = PublicLevel.friendlyImage[PublicLevel.friendlyType[i].x, PublicLevel.friendlyType[i].y];
            }
        }

        cornText.text = PublicLevel.GetCorn().ToString();

        stageButton = GameObject.FindGameObjectsWithTag("StageButton");
        foreach (GameObject stageBtn in stageButton)
        {
            StageButton stageCheck = stageBtn.GetComponent <StageButton>();
            if (stageCheck.GetStageLevel() > PublicLevel.GetPlayerLevel())
            {
                stageBtn.GetComponent <Image>().color         = Color.red;
                stageBtn.GetComponent <Button>().interactable = false;
            }
            else if (stageCheck.GetStageLevel() == PublicLevel.GetPlayerLevel())
            {
                stageBtn.GetComponent <Image>().color = Color.blue;
            }
        }

        //save data
        gameData.SaveGameData();
    }
예제 #20
0
 public void LoadGameScene()
 {
     PublicLevel.InitSetting();
     LoadingSceneManager.LoadScene("StageSelect");
 }
예제 #21
0
        public override Task Generate()
        {
            SissyLevel sissyLevel = SissyLevel.None;

            if (Settings.ContainsKey(SettingID.SissyLevel))
            {
                sissyLevel = Settings[SettingID.SissyLevel].GetValue <SissyLevel>();
            }

            PublicLevel publicLevel = PublicLevel.None;

            if (Settings.ContainsKey(SettingID.PublicLevel))
            {
                publicLevel = Settings[SettingID.PublicLevel].GetValue <PublicLevel>();
            }

            UserSetting.WheelDifficultyPreference difficulty = UserSetting.WheelDifficultyPreference.Default;
            if (Settings.ContainsKey(SettingID.WheelDifficulty))
            {
                difficulty = Settings[SettingID.WheelDifficulty].GetValue <UserSetting.WheelDifficultyPreference>();
            }

            List <WheelUserItem> clothing = Items.Where(item => WheelItemExtension.GetItemCategory((WheelItemExtension.Item)item.ItemId) == WheelItemExtension.Item.Clothing).ToList();

            int maxItemCount = Convert.ToInt32((float)difficulty / 2 * (float)sissyLevel);

            maxItemCount = maxItemCount < 1 ? 1 : maxItemCount;

            int itemCount = Helpers.RandomGenerator.RandomInt(1, maxItemCount);

            DiscordEmbedBuilder builder = new DiscordEmbedBuilder()
            {
                Title       = "Hmm, i bet you'd look cute in something else...",
                Description = "I want you, to put some of your clothes on. In fact, you'll dress up with your "
            };

            for (int i = itemCount; i > 0; i--)
            {
                if (clothing.Count == 0)
                {
                    break;
                }

                var item = clothing[Helpers.RandomGenerator.RandomInt(0, clothing.Count)];

                string postfix = "";

                postfix = i switch
                {
                    2 => " and ",

                    1 => ". ",

                    _ => ", ",
                };
                builder.Description += ((WheelItemExtension.Item)item.ItemId).ToFormattedText() + postfix;

                clothing.Remove(item);
            }

            if (sissyLevel >= SissyLevel.Normal)
            {
                switch (publicLevel)
                {
                case PublicLevel.None:
                case PublicLevel.Light:
                    builder.Description += "When you're done, leave on everything you're comfortable with for at least 2 hours.";
                    break;

                case PublicLevel.Normal:
                    builder.Description += "When you're done, leave on everything you're comfortable with for at least 4 hours.";
                    break;

                case PublicLevel.Hardcore:
                    builder.Description += "When you're done, leave on everything for at least 6 hours.";
                    break;
                }
            }
            else
            {
                builder.Description += "You can take everything off when you're done with your tasks.";
            }

            Embed = builder.Build();

            return(Task.CompletedTask);
        }