Exemplo n.º 1
0
        public BattleResults PerformProjectileHitAtPlace(MyHexPosition projectileHitPosition)
        {
            Assert.IsTrue(_units.IsPawnAt(projectileHitPosition), "There is no unit at " + projectileHitPosition);
            Assert.IsTrue(_projectiles.IsPawnAt(projectileHitPosition), "There is no projectile at " + projectileHitPosition);
            var unit                  = _units.GetPawnAt(projectileHitPosition);
            var projectile            = _projectiles.GetPawnAt(projectileHitPosition);
            var projectileOrientation = projectile.Orientation;
            var projectileEffect      = projectile.HitEffect;

            BattleEngagementResult engagementResult = new BattleEngagementResult();
            var engagement = new BattleEngagement(engagementResult);

            AddEngagementElement(projectile, unit, engagement, projectileEffect);

            projectileEffect.Execute(new BattlefieldVision(projectile, projectileOrientation, _units, _mapModel, BattleCircumstances.ProjectileHit), projectileHitPosition, engagementResult);
            var defenderSymbolOrientation = unit.Orientation.CalculateLocalDirection(projectileOrientation.Opposite());

            if (unit.Symbols.ContainsKey(defenderSymbolOrientation))
            {
                var reactEffect = unit.Symbols[defenderSymbolOrientation].ReactEffect;
                AddEngagementElement(unit, projectile, engagement, reactEffect);

                BattlefieldVision vision = new BattlefieldVision(unit, projectileOrientation, _units, _mapModel, BattleCircumstances.ProjectileHit);
                reactEffect.Execute(vision, projectileHitPosition, engagementResult);
            }
            var results = new BattleResults();

            results.Add(engagement);
            return(results);
        }
    public void AddExperience(GameObject defeatedEnemyActor)
    {
        if (defeatedEnemyActor != null)
        {
            BattleResults result    = GameManager.Instance.CalculateBattleResults(defeatedEnemyActor.GetComponent <RPGActor>());
            bool          isLevelUp = false;
            foreach (var unit in GameManager.Instance.CurrentPartyMembers)
            {
                var actor = unit.GetComponent <RPGActor>();
                var prop  = unit.GetComponent <RPGActor>().Properties;
                if (prop.CurrentHealth > 0)
                {
                    bool levelUp = prop.IncreaseExperience(result.Experience);

                    if (levelUp)
                    {
                        isLevelUp = true;
                    }
                }
            }

            //GameManager.Instance.Gold += result.Gold;
            //-> Spawn gold pickups instead
            CoreUIManager.Instance.SpawnText(result.Experience + " exp", defeatedEnemyActor);

            if (isLevelUp)
            {
                CoreUIManager.Instance.ShowBigText("Level up!");
            }
        }
        //CoreUIManager.Instance.SpawnDamageText("1 LP", this.gameObject);
    }
Exemplo n.º 3
0
 public void pbEndBattle(BattleResults result)
 {
     if (OnBattlePhase != null)
     {
         OnBattlePhase.Invoke(this, new OnBattlePhaseEventArgs {
             Phase = 0
         });
     }
 }
Exemplo n.º 4
0
    public BattleResults CalculateBattleResults(RPGActor defeatedEnemy)
    {
        //allocate exp
        BattleResults results  = default(BattleResults);
        int           expToAdd = defeatedEnemy.Properties.EarnedExperience;

        //add additional exp from passive bonusses, rest time, etc, extra gold.
        results.Experience = expToAdd;
        return(results);
    }
Exemplo n.º 5
0
        public BattleResults PerformPassiveBattleAtPlace(MyHexPosition battleActivatorPosition, BattleCircumstances battleCircumstances)
        {
            var battleResults = new BattleResults();

            var intruderUnit = _units.GetPawnAt(battleActivatorPosition);

            // First - Passive effects of all neighbours
            foreach (var pair in battleActivatorPosition.NeighboursWithDirections)
            {
                if (_mapModel.HasTileAt(pair.NeighbourPosition)) // is valid position
                {
                    if (_units.IsPawnAt(pair.NeighbourPosition))
                    {
                        var neighbourUnit = _units.GetPawnAt(pair.NeighbourPosition);
                        if (!battleResults.UnitIncapaciated(neighbourUnit))
                        {
                            battleResults.Add(PerformSingleFight(intruderUnit, neighbourUnit, pair.NeighbourDirection, symbol => symbol.PassiveEffect,
                                                                 battleCircumstances));
                            if (battleResults.UnitIncapaciated(intruderUnit))
                            {
                                return(battleResults);
                            }
                        }
                    }
                }
            }

            foreach (var pair in battleActivatorPosition.NeighboursWithDirections)
            {
                if (_mapModel.HasTileAt(pair.NeighbourPosition)) // is valid position
                {
                    if (_units.IsPawnAt(pair.NeighbourPosition))
                    {
                        var neighbourUnit = _units.GetPawnAt(pair.NeighbourPosition);
                        if (!battleResults.UnitIncapaciated(neighbourUnit))
                        {
                            battleResults.Add(PerformSingleFight(neighbourUnit, intruderUnit, pair.NeighbourDirection.Opposite(), symbol => symbol.PassiveEffect,
                                                                 battleCircumstances));

                            if (battleResults.UnitIncapaciated(intruderUnit))
                            {
                                return(battleResults);
                            }
                        }
                    }
                }
            }
            return(battleResults);
        }
 public BattleResultsSerializble(BattleResults br)
 {
     if (br != null) {
         BulletDamage = br.BulletDamage;
         BulletDamageBonus = br.BulletDamageBonus;
         First = br.Firsts;
         LastSurvivorBonus = br.LastSurvivorBonus;
         RamDamage = br.RamDamage;
         RamDamageBonus = br.RamDamageBonus;
         Rank = br.Rank;
         Score = br.Score;
         Seconds = br.Seconds;
         Survival = br.Survival;
         TeamLeaderName = br.TeamLeaderName;
         Thirds = br.Thirds;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Displays the results of a battle.
 /// </summary>
 /// <param name="player">The player.</param>
 /// <param name="enemy">The enemy.</param>
 /// <param name="battleResults">Whether the player won, lost or tied the battle.</param>
 public override void DisplayBattleResults( Player player, Enemy enemy, BattleResults battleResults )
 {
     switch( this.Mode )
     {
         case graphicsMode.CLI:
             switch( battleResults )
             {
                 case BattleResults.Victory:
                     Console.WriteLine( "{0} is victorious over the {1}! The kingdom is safe!", player.Name, enemy.Name );
                     break;
                 case BattleResults.Tie:
                     Console.WriteLine( "{0} has barely defeated the {1}. The battle was fierce and long, and the losses great, but the kingdom is safe.", player.Name, enemy.Name );
                     break;
                 case BattleResults.Loss:
                     Console.WriteLine( "{0} has suffered defeat at the hands of the {1}. The kingdom will suffer at the enemy's hand for another year.", player.Name, enemy.Name );
                     break;
             }
             break;
         case graphicsMode.GUI:
             throw new NotImplementedException();
     }
 }
    void ToBattleCallback(ExecuteCloudScriptResult result)
    {
        // output any errors that happend within cloud script
        if (result.Error != null)
        {
            Debug.LogError(string.Format("{0} -- {1}", result.Error, result.Error.Message));
            return;
        }

        Debug.Log("BATTLE REPORT:");
        BattleResults grantedItems = PlayFab.Json.JsonWrapper.DeserializeObject <BattleResults>(result.FunctionResult.ToString());

        if (grantedItems != null)
        {
            Debug.Log(string.Format("You found {0} gems. \n You lost {1} lives.", grantedItems.gemsFound, grantedItems.lostALife ? 1 : 0));
            GetInventory();
        }
        else
        {
            Debug.LogError("An error occured when attemtpting to deserialize the BattleResults.");
        }
    }
Exemplo n.º 9
0
 // Called by the game to create an instance of this event.
 // Note: This constructor should not be available in the API.
 internal BattleCompletedEvent(BattleRules battleRules, BattleResults[] results)
     : base()
 {
     this.battleRules = battleRules;
     this.results = results;
 }
Exemplo n.º 10
0
 /// 
 ///<summary>
 ///  Called by the game to create a new BattleEndedEvent.
 ///</summary>
 public BattleEndedEvent(bool aborted, BattleResults results)
 {
     this.aborted = aborted;
     this.results = results;
 }
Exemplo n.º 11
0
        private static BattleResults[] MapBattleResults(java.lang.Object[] results)
        {
            if (results == null)
            {
                return null;
            }

            BattleResults[] mappedResults = new BattleResults[results.Length];

            for (int i = 0; i < results.Length; i++)
            {
                mappedResults[i] = MapBattleResults(results[i]);
            }
            return mappedResults;
        }
Exemplo n.º 12
0
 private void Awake()
 {
     _Instance = this;
 }
Exemplo n.º 13
0
 public abstract void DisplayBattleResults(Player player, Enemy enemy, BattleResults battleResults);
Exemplo n.º 14
0
 public override void DisplayBattleResults( Player player, Enemy enemy, BattleResults battleResults )
 {
     throw new NotImplementedException();
 }