// Use this for initialization
 void Start()
 {
     if (self == null){
         print ("Error:ColliderWeaponEnemy"  + " has no host");
         this.enabled = false;
     }
     selfCombat = self.GetComponent(typeof(ICombat)) as ICombat;
     if (selfCombat == null){
         print ("Error:ColliderWeaponEnemy"  + " has no AIPathCustom");
         this.enabled = false;
     }
 }
        /// <summary>
        /// The set target function.
        /// Auto sets the object as the target for the unit.
        /// <para></para>
        /// <remarks><paramref name="theTarget"></paramref> -The object that will be set as the target for attacking.</remarks>
        /// </summary>
        public void AutoTarget(GameObject theTarget)
        {
            if (this.theEnemy == null && theTarget != null)
            {
                this.theEnemy = theTarget;

                if (this.gothitfirst)
                {
                    this.theobjecttolookat = this.theEnemy;
                }

                this.target = (ICombat)theTarget.GetComponent(typeof(ICombat));
            }
        }
 // Use this for initialization
 void Start()
 {
     if (self == null){
         print("ColliderWeapon.Start->Self not found");
         this.enabled = false;
         return;
     }
     combatSelf = self.GetComponent(typeof(ICombat)) as ICombat;
     if (combatSelf == null){
         print ("ColliderWeapon.Start->combatSelf Interface not found");
         this.enabled = false;
         return;
     }
 }
    public override bool TakeDamage(float damage, Vector2 damagePos,
                                    Entity destroyer, float dropModifier, bool flash)
    {
        bool dead = base.TakeDamage(damage, damagePos, destroyer, dropModifier, flash);

        if (dead)
        {
            return(true);
        }
        ICombat threat = destroyer.GetICombat();

        if (threat != null && threat.EngageInCombat(this))
        {
            EngageInCombat(threat);
        }
        return(false);
    }
Exemple #5
0
    public bool EngageInCombat(ICombat hostile)
    {
        if (IsSibling((Entity)hostile) || (Entity)hostile == hive)
        {
            return(false);
        }

        for (int i = 0; i < enemies.Count; i++)
        {
            if (enemies[i] == hostile)
            {
                return(false);
            }
        }
        AddThreat(hostile);
        return(true);
    }
    public void Init()
    {
        combat    = GetComponent <ICombat>();
        seeker    = GetComponent <Seeker>();
        direction = Vector2.zero;

        gm     = GameObject.Find("GameManager").GetComponent <GameManager>();
        Player = GameObject.Find("Player");

        //playerscript = Player.GetComponent<Player>();

        //Debug.Log(Player.transform.position);
        //Debug.Log(transform.position);
        //Debug.Log("StartPathFinding");
        InvokeRepeating("UpdatePath", 0f, 0.5f);

        //Debug.Log("PathFindingStarted");
    }
        /// <summary>
        /// The set target function.
        /// Auto sets the object as the target for the unit.
        /// <para></para>
        /// <remarks><paramref name="theTarget"></paramref> -The object that will be set as the target for attacking.</remarks>
        /// </summary>
        public void AutoTarget(GameObject theTarget)
        {
            if (this.theEnemy == null && theTarget != null)
            {
                this.theEnemy = theTarget;

                if (this.gothitfirst)
                {
                    this.theobjecttolookat = this.theEnemy;
                    if (Vector3.Distance(this.gameObject.transform.position, this.theobjecttolookat.transform.position) <= 5.0f)
                    {
                        this.navagent.updateRotation = false;
                    }
                }

                this.target = (ICombat)theTarget.GetComponent(typeof(ICombat));
            }
        }
    public override void Initialize(DataObject data)
    {
        base.Initialize(data);

        UnitData unitData = data as UnitData;

        if (unitData != null)
        {
            AddActor(unitData);

            this.No       = unitData.no;
            this.UnitName = unitData.name;

            _impl = new CombatInstance(unitData);
        }

        Debug_DisplayStatus();
    }
        public GameLoop(IWriteToClient writeToClient, ICache cache, ICommands commands, ICombat combat, IDataBase database, IDice dice, IUpdateClientUI client, ITime time, ICore core, ISpellList spelllist, IWeather weather)
        {
            _writeToClient = writeToClient;
            _cache         = cache;
            _commands      = commands;
            _combat        = combat;
            _db            = database;
            _dice          = dice;
            _client        = client;
            _time          = time;
            _core          = core;
            _spellList     = spelllist;
            _weather       = weather;

            if (_hints == null)
            {
                _hints = _core.Hints();
            }
        }
        public async Task IntegrationTestGetCombatWithMultipleRounds()
        {
            // Arrange
            WorldRepository  repository        = new WorldRepository(DevelopmentStorageAccountConnectionString);
            Guid             combatId          = new Guid("3233BE80-37BA-4FBD-B07B-BB18F6E47FEE");
            Guid             attackingRegionId = new Guid("5EA3D204-63EA-4683-913E-C5C3609BD893");
            Guid             defendingRegionId = new Guid("6DC3039A-CC79-4CAC-B7CE-37E1B1565A6C");
            CombatTableEntry tableEntry        = new CombatTableEntry(SessionId, 5, combatId, CombatType.Invasion);

            tableEntry.SetCombatArmy(new List <ICombatArmy>
            {
                new CombatArmy(attackingRegionId, "AttackingUser", Core.CombatArmyMode.Attacking, 5),
                new CombatArmy(defendingRegionId, "DefendingUser", Core.CombatArmyMode.Defending, 4)
            });

            CloudTable testTable = SessionRepository.GetTableForSessionData(TableClient, SessionId);

            testTable.CreateIfNotExists();
            TableOperation insertOperation = TableOperation.Insert(tableEntry);
            await testTable.ExecuteAsync(insertOperation);

            CombatTableEntry otherRoundTableEntry = new CombatTableEntry(SessionId, 2, Guid.NewGuid(), CombatType.Invasion);

            insertOperation = TableOperation.Insert(otherRoundTableEntry);
            await testTable.ExecuteAsync(insertOperation);

            // Act
            var results = await repository.GetCombat(SessionId, 5);

            // Assert
            Assert.IsNotNull(results);
            Assert.AreEqual(1, results.Count());

            ICombat result = results.Where(combat => combat.CombatId == combatId).FirstOrDefault();

            Assert.IsNotNull(result);
            Assert.AreEqual(combatId, result.CombatId);
            Assert.AreEqual(CombatType.Invasion, result.ResolutionType);
            Assert.AreEqual(2, result.InvolvedArmies.Count());

            AssertCombat.IsAttacking(attackingRegionId, 5, "AttackingUser", result);
            AssertCombat.IsDefending(defendingRegionId, 4, "DefendingUser", result);
        }
        public async Task IntegrationTestAddCombat()
        {
            // Arrange
            WorldRepository repository        = new WorldRepository(DevelopmentStorageAccountConnectionString);
            Guid            attackingRegionId = new Guid("4CD8D6E1-8FFE-48E1-8FE0-B89BCDD0AA96");
            Guid            defendingRegionId = new Guid("E0FE9A73-4125-4DA1-A113-25ED927EA7B4");

            CloudTable testTable = SessionRepository.GetTableForSessionData(TableClient, SessionId);

            testTable.CreateIfNotExists();

            // Act
            using (IBatchOperationHandle batchOperation = new BatchOperationHandle(testTable))
            {
                repository.AddCombat(batchOperation, SessionId, 2, new List <Tuple <CombatType, IEnumerable <ICombatArmy> > >
                {
                    Tuple.Create <CombatType, IEnumerable <ICombatArmy> >(CombatType.MassInvasion, new List <ICombatArmy>
                    {
                        new CombatArmy(attackingRegionId, "AttackingUser", Core.CombatArmyMode.Attacking, 5),
                        new CombatArmy(defendingRegionId, "DefendingUser", Core.CombatArmyMode.Defending, 4)
                    })
                });
            }

            // Assert
            IEnumerable <ICombat> combatList = await repository.GetCombat(SessionId, 2);

            Assert.IsNotNull(combatList);
            Assert.AreEqual(1, combatList.Count());
            ICombat combat = combatList.First();

            Assert.IsInstanceOfType(combat, typeof(CombatTableEntry));
            CombatTableEntry resultStronglyTyped = combat as CombatTableEntry;

            Assert.AreEqual(SessionId, resultStronglyTyped.SessionId);
            Assert.IsNotNull(resultStronglyTyped.CombatId);
            Assert.AreEqual(CombatType.MassInvasion, resultStronglyTyped.ResolutionType);
            Assert.AreEqual(2, resultStronglyTyped.InvolvedArmies.Count());

            AssertCombat.IsAttacking(attackingRegionId, 5, "AttackingUser", resultStronglyTyped);
            AssertCombat.IsDefending(defendingRegionId, 4, "DefendingUser", resultStronglyTyped);
        }
Exemple #12
0
 protected override bool CheckHealth(Entity destroyer, float dropModifier)
 {
     if (HealthRatio > 0f)
     {
         return(false);
     }
     destroyerEntity     = destroyer;
     dropModifierOnDeath = dropModifier;
     burning             = true;
     burningEffects.SetActive(true);
     ActivateAllColliders(false);
     sprRend.sprite = burningSprite;
     for (int i = 0; i < enemies.Count; i++)
     {
         ICombat enemy = enemies[i];
         enemy.DisengageInCombat(this);
     }
     EjectFromAllDrillers(true);
     return(base.CheckHealth(destroyer, dropModifier));
 }
Exemple #13
0
        private bool IsStillValid(ISession session, ICombat combat)
        {
            switch (session.PhaseType)
            {
            case SessionPhase.BorderClashes:
                return(true);

            case SessionPhase.MassInvasions:
                return(combat.ResolutionType >= CombatType.MassInvasion);

            case SessionPhase.Invasions:
                return(combat.ResolutionType >= CombatType.Invasion);

            case SessionPhase.SpoilsOfWar:
                return(combat.ResolutionType >= CombatType.SpoilsOfWar);

            default:
                return(false);
            }
        }
Exemple #14
0
    private bool IsSuspicious(ICombat threat)
    {
        if (threat == null || threat == GetICombat())
        {
            return(false);
        }

        Entity e = (Entity)threat;

        //ignore if too far away
        if (Vector2.Distance(transform.position, e.transform.position) > suspiciousChaseRange)
        {
            return(false);
        }

        for (int i = 0; i < unsuspiciousEntities.Count; i++)
        {
            if (unsuspiciousEntities[i] == e)
            {
                return(false);
            }
        }

        //determine suspect based on entity type
        EntityType type = e.GetEntityType();

        if (type == EntityType.Shuttle)
        {
            return(true);
        }
        if (type == EntityType.BotHive)
        {
            return((Entity)threat != hive);
        }
        if (type == EntityType.GatherBot)
        {
            return(!IsSibling(e));
        }

        return(false);
    }
 public Commands(
     IMovement movement,
     IRoomActions roomActions,
     IDebug debug,
     ISkills skills,
     ISpells spells,
     IObject objects,
     IInventory inventory,
     Icommunication communication,
     IEquip equipment,
     IScore score,
     ICombat combat,
     ICache cache,
     ISocials socials,
     ICommandHandler commandHandler,
     ICore core,
     IMobFunctions mobFunctions,
     IHelp help,
     IMobScripts mobScripts
     )
 {
     _movement       = movement;
     _roomActions    = roomActions;
     _debug          = debug;
     _skills         = skills;
     _spells         = spells;
     _object         = objects;
     _inventory      = inventory;
     _communication  = communication;
     _equipment      = equipment;
     _score          = score;
     _combat         = combat;
     _cache          = cache;
     _socials        = socials;
     _commandHandler = commandHandler;
     _core           = core;
     _mobFunctions   = mobFunctions;
     _help           = help;
     _mobScripts     = mobScripts;
 }
Exemple #16
0
    }                               //yohan added


    public virtual void Init()
    {
        // Initialization

        if (gameObject.name == "Player")
        {
            //stats = SaveSystem.LoadStats();
            //stats.maxHP = SaveSystem.LoadStats().maxHP;
            stats = new Stats(initHP, initAtt, initSpeed, initAttSpeed, initDefence, initCriticalChance);
        }
        else
        {
            stats = new Stats(initHP, initAtt, initSpeed, initAttSpeed, initDefence, initCriticalChance);
        }
        InitInput();
        InitInventory();
        movement = GetComponent <IMovement>();
        combat   = GetComponent <ICombat>();
        movement.Init(this);
        combat.Init(this);
        gm = GameObject.FindWithTag("GameController").GetComponent <GameManager>();
        damageTextPrefab = Resources.Load <GameObject>("Prefabs/DamageText");
        dialogTextPrefab = Resources.Load <GameObject>("Prefabs/StateUIs/FloatingDialog");
        GameObject stateUIInstance = Instantiate(stateUIPrefab, Vector3.zero, Quaternion.identity) as GameObject;

        stateUI = stateUIInstance.GetComponentInChildren <StateUI>();
        InitStateUI();

        animationManager = GetComponent <AnimationManager>();
        if (animationManager != null)
        {
            animationManager.Init();
        }
        IsAlive              = true;
        ActivateAutoAim      = true;
        drops                = new Drops(creditDrop, energyDrop);
        gm.WorldColorChange += OnWorldColorChange;
        audioManager         = FindObjectOfType <AudioManager>();
    }
Exemple #17
0
        /// <summary>
        /// The battle state function.
        /// The function called while in the battle state.
        /// </summary>
        private void BattleState()
        {
            if (this.target != null)
            {
                this.Attack();

                // If the unit has died
                if (this.Currenttarget == null)
                {
                    this.target = null;
                    this.ChangeStates("Idle");
                }
                // If unit is alive but out of range
                else if (Vector3.Distance(this.Currenttarget.transform.position, this.transform.position) > this.GetComponent <EnemyAI>().Radius)
                {
                    this.Currenttarget = null;
                    this.target        = null;
                    this.ChangeStates("Idle");
                    this.GetComponent <EnemyAI>().taunted = false;
                }
            }
        }
Exemple #18
0
        public MainWindow()
        {
            InitializeComponent();

            TextBoxStreamWriter consoleWriter = new TextBoxStreamWriter(textBox);

            Console.SetOut(consoleWriter);

            //Initalize variables
            IList <ICharacter> playerParty     = new List <ICharacter>();
            IList <ICharacter> enemyParty      = new List <ICharacter>();
            string             playerPartyName = "Heroes";
            string             enemyPartyName  = "Villains";

            //Create player characters
            ICharacter player1 = new ImageMage("Harry Potter", 41, characterImage);
            ICharacter player2 = new ImageWarrior("Carl Sagan", 110, characterImage1);

            //Create enemy characters
            ICharacter enemy1 = new ImageArcher("Voldemort", 90, characterImage2);
            ICharacter enemy2 = new ImageComputerWizard("Neil deGrasse Tyson", 41, characterImage3);

            //Add players to party
            playerParty.Add(player1);
            playerParty.Add(player2);

            //Add enemys to party
            enemyParty.Add(enemy1);
            enemyParty.Add(enemy2);

            //Initalize combat
            encounter = new Combat(playerParty, enemyParty, playerPartyName, enemyPartyName);

            CombatThread combatThread = new CombatThread(encounter);

            combatThread.Start();
        }
        static public void IsResultValid(UInt32 numberOfRounds, ICombat sourceCombat, ICombatResult result)
        {
            Assert.AreEqual(numberOfRounds, (UInt32)result.Rounds.Count());
            Assert.AreEqual(sourceCombat.InvolvedArmies.Where(army => army.NumberOfTroops > 0).Count(), result.Rounds.First().ArmyResults.Count());

            foreach (ICombatRoundResult round in result.Rounds)
            {
                foreach (ICombatArmy army in sourceCombat.InvolvedArmies)
                {
                    var armyResults = round.ArmyResults.Where(armyResult => armyResult.OriginRegionId == army.OriginRegionId).FirstOrDefault();
                    if (armyResults != null)
                    {
                        Assert.IsNotNull(armyResults.RolledResults);
                        Assert.AreEqual(army.OwnerUserId, armyResults.OwnerUserId);
                        if (army.ArmyMode == CombatArmyMode.Defending)
                        {
                            Assert.IsTrue(2 >= armyResults.RolledResults.Count() && 1 <= armyResults.RolledResults.Count(), "Defender can only roll 1 or 2 dice");
                        }
                        else
                        {
                            Assert.IsTrue(3 >= armyResults.RolledResults.Count() && 1 <= armyResults.RolledResults.Count(), "Attacker can only roll 1, 2 or 3 dice");
                        }

                        switch (sourceCombat.ResolutionType)
                        {
                        case CombatType.BorderClash:
                            Assert.IsTrue(3 >= armyResults.TroopsLost, "An army cannot lose more than three troops in a round");
                            break;

                        case CombatType.Invasion:
                            Assert.IsTrue(2 >= armyResults.TroopsLost, "An army cannot lose more than two troops in a round");
                            break;
                        }
                    }
                }
            }
        }
Exemple #20
0
    public override void DestroySelf(Entity destroyer, float dropModifier)
    {
        bool explode = destroyer != null;

        if (explode)
        {
            //particle effects
            GameObject explosion = Instantiate(explosionDeathObj, ParticleGenerator.holder);
            explosion.transform.position = transform.position;

            //sound effects
        }
        for (int i = 0; i < enemies.Count; i++)
        {
            ICombat enemy = enemies[i];
            enemy.DisengageInCombat(this);
        }
        if (hive != null)
        {
            hive.BotDestroyed(this);
        }

        base.DestroySelf(destroyer, dropModifier);
    }
Exemple #21
0
        /// <summary>
        /// The change states function.
        /// This function changes the state to the passed in state.
        /// <para></para>
        /// <remarks><paramref name="destinationState"></paramref> -The state to transition to.</remarks>
        /// </summary>
        public void ChangeStates(string destinationState)
        {
            string thecurrentstate = this.theEnemyFSM.CurrentState.Statename;

            switch (destinationState)
            {
            case "Battle":
                this.target = (ICombat)this.Currenttarget.GetComponent(typeof(ICombat));
                this.theEnemyFSM.Feed(thecurrentstate + "To" + destinationState);
                break;

            case "Idle":
                this.theEnemyFSM.Feed(thecurrentstate + "To" + destinationState);
                break;

            case "TaintResource":
                this.targetResource = (IResources)this.Currenttarget.GetComponent(typeof(IResources));
                this.theEnemyFSM.Feed(thecurrentstate + "To" + destinationState);
                break;

            default:
                break;
            }
        }
Exemple #22
0
        /// <summary>
        /// The attack function gives the extractor functionality to attack.
        /// </summary>
        public void Attack()
        {
            // If unit died and was about to attack then just return
            if (this.mystats.Health <= 0)
            {
                return;
            }

            // If enemy died
            if (this.theEnemy.GetComponent <Stats>().Health <= 0)
            {
                //this.theEnemy = null;
                this.gothitfirst = true;
                this.target      = null;
                this.animatorcontroller.SetTrigger("Idle");
                this.navagent.SetDestination(this.gameObject.transform.position);
                this.ChangeStates("Idle");
            }// Else if its time to attack
            else if (this.timebetweenattacks >= this.mystats.Attackspeed && this.navagent.velocity == Vector3.zero)
            {
                this.timebetweenattacks = 0;
                this.animatorcontroller.SetTrigger("AttackTrigger");
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            consoleWriter = new TextBoxStreamWriter(TextBox);
            Console.SetOut(consoleWriter);

            ICharacter mage           = new MageHero(mageImage);
            ICharacter warrior        = new WarriorHero(warriorImage);
            ICharacter archer         = new ArcherHero(archerImage);
            ICharacter computerWizard = new ComputerWizardHero(computerWizardImage);

            IList <ICharacter> friendlyParty = new List <ICharacter>();
            IList <ICharacter> enemyParty    = new List <ICharacter>();

            friendlyParty.Add(warrior);
            enemyParty.Add(mage);
            enemyParty.Add(archer);
            enemyParty.Add(computerWizard);

            combat = new Combat(friendlyParty, enemyParty, "Good Guys", "Baddies");

            combatThread = new CombatThread(combat);
            combatThread.Start();
        }
Exemple #24
0
 public GameLoop(IWriteToClient writeToClient, ICache cache, ICommands commands, ICombat combat, IDataBase database, IDice dice, IUpdateClientUI client)
 {
     _writeToClient = writeToClient;
     _cache         = cache;
     _commands      = commands;
     _combat        = combat;
     _db            = database;
     _dice          = dice;
     _client        = client;
 }
Exemple #25
0
    protected virtual void Scanning()
    {
        if (rb.velocity.sqrMagnitude < 0.01f)
        {
            if (!scanStarted)
            {
                if (IsInViewRange)
                {
                    StartCoroutine(ScanRings());
                }
                scanStarted = true;
                entitiesScanned.Clear();
                new Thread(() =>
                {
                    EntityNetwork.IterateEntitiesInRange(
                        coords,
                        1,
                        e =>
                    {
                        if (e != this)
                        {
                            entitiesScanned.Add(e);
                        }

                        return(false);
                    });
                }).Start();
            }
            else
            {
                scanTimer += Time.deltaTime;
            }

            if (scanTimer >= scanDuration)
            {
                scanTimer   = 0f;
                scanStarted = false;
                //look for the first unusual entity in the scan
                for (int i = 0; i < entitiesScanned.Count; i++)
                {
                    Entity e = entitiesScanned[i];
                    if (IsScary(e))
                    {
                        hive?.MarkCoordAsEmpty(coords);
                        SetState(AIState.Exploring);
                        return;
                    }
                    ICombat threat = e.GetICombat();
                    if (threat != null && IsSuspicious(threat))
                    {
                        nearbySuspects.Add(threat);
                    }
                }

                if (nearbySuspects.Count > 0)
                {
                    SetState(AIState.Suspicious);
                    return;
                }

                //choose state
                if (entitiesScanned.Count >= 10)
                {
                    SetState(AIState.Gathering);
                }
                else
                {
                    hive?.MarkCoordAsEmpty(coords);
                    SetState(AIState.Exploring);
                }
            }
        }
    }
Exemple #26
0
 public Movement(IWriteToClient writeToClient, ICache cache, IRoomActions roomActions, IUpdateClientUI updateUI, IDice dice, ICombat combat, IMobScripts mobScripts)
 {
     _writeToClient = writeToClient;
     _cache         = cache;
     _roomActions   = roomActions;
     _updateUi      = updateUI;
     _dice          = dice;
     _combat        = combat;
     _mobScripts    = mobScripts;
 }
Exemple #27
0
 public void Alert(ICombat threat)
 {
     AddThreat(threat);
     SetState(AIState.Attacking);
 }
        static public void IsAttacking(Guid regionId, UInt32 numberOfTroops, String ownerId, ICombat combat)
        {
            var atatckingArmy = combat.InvolvedArmies.Where(army => army.ArmyMode == CombatArmyMode.Attacking && army.OriginRegionId == regionId);

            Assert.AreEqual(1, atatckingArmy.Count(), "Could not find attacking army");
            Assert.AreEqual(numberOfTroops, atatckingArmy.First().NumberOfTroops);
            Assert.AreEqual(ownerId, atatckingArmy.First().OwnerUserId);
        }
Exemple #29
0
        private MapEvent move(int newX, int newY)
        {
            if (!MapDataClasses.MapDataManager.getTraversable(currentMap.map[newX, newY]))
            {
                return MapEvent.Nothing;
            }

            player.rootX = newX;
            player.rootY = newY;

            if(MapDataClasses.MapDataManager.isEvent(currentMap, newX, newY))
            {
                MapDataClasses.MapEventModel mapEvent = MapDataClasses.MapDataManager.getEvent(currentMap, newX, newY);

                switch (mapEvent.eventData.type)
                {
                    case MapDataClasses.EventClasses.EventDataType.Combat:
                        player.getActiveParty().location.activeEvent = mapEvent;
                        combat = combatDirector.getCombat();
                        return MapEvent.CombatEntered;
                    case MapDataClasses.EventClasses.EventDataType.EmergenceCavernCeilingCollapse:
                        //Deal damage to each character
                        foreach (PartyCharacterModel pcm in player.getActiveParty().characters)
                        {
                            foreach (CharacterModel cm in player.characters)
                            {
                                if (cm.uniq == pcm.characterUniq)
                                {
                                    pcm.hp = pcm.hp - 10;
                                    if(pcm.hp <= 0)
                                    {
                                        pcm.hp = 0;
                                    }
                                }
                            }
                        }
                        messageQueue.Add(new ClientMessage(){
                            type = ClientMessage.ClientMessageType.Message,
                            message = "The roof collapsed above you!  All characters take 10 damage."
                        });
                        PlayerDataManager.processEvent(mapEvent, this.player, ref messageQueue);
                        return MapEvent.UpdateMessageQueue;
                    default:
                        return MapEvent.Nothing;
                }
            }
            else if (isCombat())
            {
                combat = combatDirector.getCombat();
                return MapEvent.CombatEntered;
            }
            return MapEvent.Nothing;
        }
Exemple #30
0
 public ICombatStatus getStatus()
 {
     if (combat == null) //Game loaded without combat being loaded normally
     {
         combatCountdown = 0;
         isCombat(); //This will cause it to init the combatCountdown properly
         combat = combatDirector.getCombat();
     }
     return combat.getStatus();
 }
Exemple #31
0
        /// <summary>
        ///     Parses the combat.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>The combat.</returns>
        private ICombat ParseCombat(XElement element)
        {
            ICombat combat;

            if (!(element.Attribute("name") is XAttribute nameAttribute))
            {
                throw new ArgumentNullException(nameof(nameAttribute));
            }

            string combatName = nameAttribute.Value;

            switch (combatName)
            {
            case "healing":
                combat = ParseHealingCombatData(element);
                break;

            case "invisible":
                combat = ParseInvisibleCombatData(element);
                break;

            case "melee":
                combat = ParseMeleeCombatData(element);
                break;

            case "physical":
                combat = ParsePhysicalDamage(element);
                break;

            case "speed":
                combat = ParseSpeedCombatData(element);
                break;

            case "paralyze":
                combat = ParseParalyzeCombatData(element);
                break;

            case "earth":
                combat = ParseEarthCombatData(element);
                break;

            case "manadrain":
                combat = ParseManaDrainCombatData(element);
                break;

            case "fire":
                combat = ParseFireCombatData(element);
                break;

            case "death":
                combat = ParseDeathCombatData(element);
                break;

            case "energy":
                combat = ParseEnergyCombatData(element);
                break;

            case "ice":
                combat = ParseIceCombatData(element);
                break;

            case "poison":
                combat = ParsePoisonCombatData(element);
                break;

            case "poisonfield":
                combat = ParsePoisonFieldCombatData(element);
                break;

            case "firefield":
                combat = ParseFireFieldCombatData(element);
                break;

            case "energyfield":
                combat = ParseEnergyFieldCombatData(element);
                break;

            case "drunk":
                combat = ParseDrunkCombatData(element);
                break;

            case "holy":
                combat = ParseHolyCombatData(element);
                break;

            case "lifedrain":
                combat = ParseLifeDrainCombatData(element);
                break;

            case "drown":
                combat = ParseDrowningCombatData(element);
                break;

            case "outfit":
                combat = ParseOutfitCombatData(element);
                break;

            case "poisoncondition":
                combat = ParsePoisonConditionCombatData(element);
                break;

            case "drowncondition":
                combat = ParseDrownConditionCombatData(element);
                break;

            case "firecondition":
                combat = ParseFireConditionCombatData(element);
                break;

            case "energycondition":
                combat = ParseEnergyConditionCombatData(element);
                break;

            case "cursecondition":
                combat = ParseCurseConditionCombatData(element);
                break;

            case "freezecondition":
                combat = ParseFreezeConditionCombatData(element);
                break;

            case "bleedcondition":
                combat = ParseBleedConditionCombatData(element);
                break;

            case "strength":
                combat = ParseStrengthCombatData(element);
                break;

            case "fireball":
                combat = ParseFireballCombatData(element);
                break;

            case "icicle":
                combat = ParseIcicleCombatData(element);
                break;

            case "soulfire":
                combat = ParseSoulfireCombatData(element);
                break;

            case "thunderstorm":
                combat = ParseThunderstormCombatData(element);
                break;

            case "effect":
                combat = ParseEffectCombatData(element);
                break;

            default:
                ICombat spell = _spellService.Spells.OfType <InstantSpell>().FirstOrDefault(s => string.Equals(s.Name, combatName, StringComparison.InvariantCultureIgnoreCase));
                combat = spell ?? throw new ArgumentOutOfRangeException(nameof(combatName), combatName, null);
                break;
            }

            if (element.Attribute("interval") is XAttribute intervalAttribute)
            {
                combat.Interval = TimeSpan.FromMilliseconds(long.Parse(intervalAttribute.Value));
            }

            return(combat);
        }
        static public void IsDefending(Guid regionId, UInt32 numberOfTroops, String ownerId, ICombat combat)
        {
            var defendingArmy = combat.InvolvedArmies.Where(army => army.ArmyMode == CombatArmyMode.Defending).FirstOrDefault();

            Assert.IsNotNull(defendingArmy, "No defending army in combat");
            Assert.AreEqual(numberOfTroops, defendingArmy.NumberOfTroops);
            Assert.AreEqual(regionId, defendingArmy.OriginRegionId);
            Assert.AreEqual(ownerId, defendingArmy.OwnerUserId);
        }
Exemple #33
0
    public void AddStatus(Status status)
    {
        _impl = new CombatAddedDeco(_impl, status);

        Debug_DisplayStatus();
    }
Exemple #34
0
    protected virtual void Suspicious()
    {
        if (nearbySuspects.Count == 0)
        {
            SetState(AIState.Scanning);
            return;
        }
        targetEntity = (Entity)nearbySuspects[0];
        //if target is too far away then return to exploring
        if (targetEntity == null ||
            Vector2.Distance(targetEntity.transform.position, transform.position) > suspiciousChaseRange)
        {
            intenseScanTimer = 0f;
            nearbySuspects.RemoveAt(0);
            suspicionMeter.gameObject.SetActive(false);
            suspicionMeter.material.SetFloat("_ArcAngle", 0);
            return;
        }

        //follow entity
        GoToLocation(targetEntity.transform.position, true, intenseScanRange, true, targetEntity.transform.position);
        if (Vector2.Distance(transform.position, targetEntity.transform.position) <= intenseScanRange)
        {
            //scan entity if close enough
            intenseScanTimer += Time.deltaTime;

            //draw scanner particles
            if (!intenseScanner.isPlaying)
            {
                intenseScanner.Play();
            }
            float angle = -Vector2.SignedAngle(Vector2.up, targetEntity.transform.position - transform.position);
            intenseScanner.transform.eulerAngles = Vector3.forward * -angle;
            intenseScanner.transform.localScale  = Vector3.one *
                                                   Vector2.Distance(transform.position, targetEntity.transform.position);

            //draw suspicion meter
            suspicionMeter.gameObject.SetActive(true);
            suspicionMeter.material.SetFloat("_ArcAngle", intenseScanTimer / intenseScanDuration * 360f);

            //check if scan is complete
            if (intenseScanTimer >= intenseScanDuration)
            {
                intenseScanner.Stop();
                suspicionMeter.gameObject.SetActive(false);
                suspicionMeter.material.SetFloat("_ArcAngle", 0);
                //scan complete
                intenseScanTimer = 0f;
                //assess threat level and make a decision
                AttackViability threatLevel = EvaluateScan(targetEntity.ReturnScan());
                switch (threatLevel)
                {
                case AttackViability.AttackAlone:
                    ICombat enemy = targetEntity.GetICombat();
                    if (!(bool)enemy?.EngageInCombat(this))
                    {
                        break;
                    }
                    EngageInCombat(enemy);
                    SetState(AIState.Attacking);
                    break;

                case AttackViability.SignalForHelp:
                    enemy = targetEntity.GetICombat();
                    if (!(bool)enemy?.EngageInCombat(this))
                    {
                        break;
                    }
                    EngageInCombat(enemy);
                    SetState(AIState.Signalling);
                    break;

                case AttackViability.Escape:
                    hive?.MarkCoordAsEmpty(targetEntity.GetCoords());
                    scaryEntities.Add(targetEntity);
                    SetState(AIState.Exploring);
                    break;

                case AttackViability.Ignore:
                    unsuspiciousEntities.Add((Entity)nearbySuspects[0]);
                    nearbySuspects.RemoveAt(0);
                    break;
                }
            }
        }
        else
        {
            intenseScanner.Stop();
        }
        suspicionMeter.transform.position = (Vector2)transform.position + meterRelativePosition;
    }
Exemple #35
0
 public override void init()
 {
     unit = GetComponent<ICombat>();
     nav = GetComponent<INavigation>();
 }