Example #1
0
        public void SaveConfig(string name)
        {
            JsonSerializerOptions options = new JsonSerializerOptions
            {
                PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
                WriteIndented        = true
            };
            GameInfo gameInfo = GetGameInfo(name, options);

            gameInfo.Version++;
            MoveToDir(@".\ToUpload\" + name, @Base.Config.Config().FolderApi + @"\" + name);
            gameInfo.RemoteGameInfo.Clear();

            /* for (int i = AllFolder.Count - 1; i > 0; i--)
             * {
             *   gameInfo.RemoteGameInfo.Add(AllFolder.ElementAt(i));
             * }*/
            foreach (FolderInfo info in AllFolder)
            {
                gameInfo.RemoteGameInfo.Add(info);
            }
            GameMeta     gameMeta     = GetGameMeta(options);
            GameMetaInfo gameMetaInfo = gameMeta.GetGameMeta(name);

            gameMetaInfo.Game = name;
            File.WriteAllText(@Base.Config.Config().FolderApi + @"\api.json", JsonSerializer.Serialize(gameMeta, options));
            File.WriteAllText(@Base.Config.Config().FolderApi + @"\" + name + ".json", JsonSerializer.Serialize(gameInfo, options));
            AllFolder.Clear();
            gameInfo.RemoteGameInfo.Clear();
        }
Example #2
0
    //Initialise stat modifiers dictionary with base modifier value and subscribe to onDeath event
    protected void Awake()
    {
        onDeath += InvokeDeathEvent;  //Unsubscribe in OnDisable

        //Set ability costs
        abilityAmounts = new Dictionary <Abilities, float>();
        foreach (Abilities ability in Enum.GetValues(typeof(Abilities)))
        {
            if (GameMetaInfo._Is_Instant_Ability(ability))
            {
                abilityAmounts.Add(ability, instantAbilityAmount);
            }
            else if (GameMetaInfo._Is_AoE_Ability(ability))
            {
                abilityAmounts.Add(ability, areaAbilityAmount);
            }
            else if (GameMetaInfo._Is_Defense_Ability(ability))
            {
                abilityAmounts.Add(ability, areaAbilityAmount);
            }
        }

        //Initialise Stat Modifiers and Values - Stats Enum as key, Stat Class with type (Stats) and value - Default val: 1
        statModifiers = new Dictionary <Stats, Stat>();
        foreach (Stats stat in Enum.GetValues(typeof(Stats)))
        {
            Stat newStat = new Stat(stat, defaultModifierValue);
            statModifiers.Add(newStat.StatType, newStat);
        }
    }
Example #3
0
 //Kebyind & UI button accesses this from controller (Start @ 1 to correspond to player UI)
 public void SelectAbility(Abilities choice)
 {
     if (unlockedAbilities.Contains(choice))
     {
         if (!GameMetaInfo._Is_AoE_Ability(choice))
         {
             CancelAoE();
         }
         SelectedAbility = choice;
     }
 }
Example #4
0
 /// <summary>
 /// AI Should use this interface method to attack
 /// </summary>
 /// <param name="target">Target if one is selected. Null if not</param>
 /// <returns>Returns true when damage can be applied to the target's stats (once the attack has been executed)</returns>
 public void AIUseSelected(Transform target)
 {
     SetTarget(target);
     UseAbility();
     if (!GameMetaInfo._Is_Defense_Ability(SelectedAbility))
     {
         if (targetEnemy != null)
         {
             targetEnemy.Influence(gameObject, Emotion.Anger, statComponent.agro);
         }
     }
 }
Example #5
0
 void Awake()
 {
     if (metaInfoInstance == null)
     {
         metaInfoInstance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(this);
     }
 }
Example #6
0
    /// <summary>
    /// Select a random ability and attempt to use on the selected target. Follows target.
    /// Otherwise, move about in a circle and attepmt to calm down.
    /// </summary>
    public override void Execute()
    {
        int       randomIndex = Random.Range(0, abilComponent.unlockedAbilities.Count);
        Abilities ability     = abilComponent.unlockedAbilities[randomIndex];

        abilComponent.SelectAbility(ability);

        Transform newTarget = SelectTarget();

        if (newTarget != target)
        {
            target = newTarget;
        }

        if (target != null)
        {
            //if target in range
            if ((target.position - owner.Position).sqrMagnitude < owner.stats.sqrMaxTargetDistance)
            {
                //if hostile target
                if (HostileToCurrentTarget())
                {
                    //if offense ability, attack
                    if (!GameMetaInfo._Is_Defense_Ability(abilComponent.SelectedAbility))
                    {
                        //Debug.Log("Attacking");
                        abilComponent.AIUseSelected(target);
                    }
                    //if defense ability, use on self if hostile target
                    else
                    {
                        abilComponent.AIUseSelected(owner.transform);
                    }
                }
                //if target not hostile, but ability is a defense ability, use it on them
                else if (GameMetaInfo._Is_Defense_Ability(abilComponent.SelectedAbility))
                {
                    abilComponent.AIUseSelected(target);
                }
            }
            owner.MoveTo(target.position);
        }
        else
        {
            if (owner.DestinationReached())
            {
                owner.MoveToRandomWaypoint();
            }
        }
    }
Example #7
0
        private static IGameWithMetaInfo GenerateDatabaseGame(
            int ID,
            GameSize size,
            GameDifficulty difficulty,
            int[] rowTallyData,
            int[] columnTallyData,
            int[] shipSettingsData,
            IEnumerable <Tuple <GridPoint, BimaruValue> > initialFieldValues
            )
        {
            var metaInfo = new GameMetaInfo(ID, size, difficulty);
            var game     = GenerateGame(rowTallyData, columnTallyData, shipSettingsData, initialFieldValues);

            return(new GameWithMetaInfo(metaInfo, game));
        }
Example #8
0
    public void PlayGame()
    {
        GameMetaInfo.Instance.SetPlayer1();
        GameMetaInfo.Instance.SetPlayer1Name(player1Text.text);
        if (GameMetaInfo.Instance.PlayerName == "")
        {
            GameMetaInfo.Instance.SetPlayer1Name("Player 1");
        }

        GameMetaInfo.Instance.SetPlayer2Name(player2Text.text);
        if (GameMetaInfo.Instance.OtherPlayerName == "")
        {
            GameMetaInfo.Instance.SetPlayer2Name("Player 2");
        }

        GameMetaInfo.StartGame();
    }
Example #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            GameMetaInfo gameInfo = Downloader.AllGameMeta.GameList.Values.ToList()[ListGame.SelectedIndex];

            if (Downloader.CheckGameUpdate(gameInfo.Game))
            {
                Downloader.Download(gameInfo.Game);
                return;
            }
            if (!SteamInfo.WroteIdentitity(@"./" + gameInfo.Game))
            {
                LogWarning("Impossible de récupérer votre compte steam , merci de relanecr ou lancer steam");
                return;
            }
            ProcessStartInfo startInfo = new ProcessStartInfo(@"./" + gameInfo.Game + gameInfo.ExeName);

            startInfo.Arguments        = gameInfo.LaunchCommand;
            startInfo.WorkingDirectory = Environment.CurrentDirectory + "/" + gameInfo.Game;
            Process.Start(startInfo);
        }
Example #10
0
    /// <summary>
    /// Calculates damage or heal amount based upon ability costs
    /// </summary>
    private float CalculateAbilDamage(Abilities ability)
    {
        float damage = 0f;

        //Damage dependent upon NPC ability cost, health, and then damage modifier. Increase in health/Decreases in cost will increase the damage the NPC can do.
        if (GameMetaInfo._Is_Instant_Ability(ability))
        {
            damage = instantAbilityAmount;
        }
        else if (GameMetaInfo._Is_AoE_Ability(ability))
        {
            damage = areaAbilityAmount;
        }
        else if (GameMetaInfo._Is_Defense_Ability(ability))
        {
            damage = defenseAbilityAmount;
        }
        damage /= 2;

        damage *= statModifiers[Stats.DamageModifier].StatValue;
        return(damage);
    }
Example #11
0
        internal void SelectGame(GameMetaInfo gameInfo)
        {
            GameLabel.Text           = gameInfo.Label;
            GameLabel.Visible        = true;
            TextBox.Visible          = true;
            DownloadButtonUI.Visible = true;
            ThreadManager.AddAsyncTask(async() =>
            {
                await Task.Delay(500);

                ResetTextBox();
                AddTextBox("Vérification des fichier");
                ChangeDownloadButtonText("Vérification de jeux");
                if (Downloader.CheckGameUpdate(gameInfo.Game))
                {
                    ChangeDownloadButtonText("Mise à jour");
                }
                else
                {
                    ChangeDownloadButtonText("Jouer");
                }
            });
        }
Example #12
0
    private bool UseAbility()
    {
        float damageToDo = 0f;
        bool  aoePlaced  = false;

        if (Time.time > globalCooldownFinishTime)
        {
            switch (SelectedAbility)
            {
            case Abilities.Zap:
                if (statComponent.TryUseAbility(SelectedAbility, out damageToDo))
                {
                    Zap(damageToDo);
                }
                break;

            case Abilities.Confuse:
                if (Time.time > confuseFinishTime)
                {
                    if (statComponent.TryUseAbility(SelectedAbility, out damageToDo))
                    {
                        Confuse();
                    }
                }
                break;

            case Abilities.Vortex:
                if (Time.time > aoeFinishTime)
                {
                    AoE(vortexPrefab, ref aoePlaced, SelectedAbility);
                    if (aoePlaced)
                    {
                        globalCooldownFinishTime = Time.time + globalCooldown;
                        if (OnPlayerAbilityUsed != null)
                        {
                            OnPlayerAbilityUsed.Invoke();
                        }
                    }
                }
                break;

            case Abilities.Singularity:
                if (Time.time > aoeFinishTime)
                {
                    AoE(singularityPrefab, ref aoePlaced, SelectedAbility);
                    if (aoePlaced)
                    {
                        globalCooldownFinishTime = Time.time + globalCooldown;
                        if (OnPlayerAbilityUsed != null)
                        {
                            OnPlayerAbilityUsed.Invoke();
                        }
                    }
                }
                break;

            case Abilities.Heal:
                if (Time.time > healFinishTime)
                {
                    if (statComponent.TryUseAbility(SelectedAbility, out damageToDo))
                    {
                        StartCoroutine(Heal(damageToDo));
                        if (OnPlayerAbilityUsed != null)
                        {
                            OnPlayerAbilityUsed.Invoke();
                        }
                    }
                }
                break;
            }
            //Add to GCD if not an AoE - AoEs handle cooldown with bool check to verify they have actually been placed
            if (!GameMetaInfo._Is_AoE_Ability(SelectedAbility))
            {
                globalCooldownFinishTime = Time.time + globalCooldown;  //Handle global cooldown
                if (OnPlayerAbilityUsed != null)
                {
                    OnPlayerAbilityUsed.Invoke();
                }
            }
            return(true);
        }
        return(false);
    }