示例#1
0
    public void LearnFromAI()
    {
        //select a teacher (using queue instead of rando so we get a healthy balance of peeps)
        CreatureLogic learnFrom = null;

        while (learnFrom == null)
        {
            learnFrom = manager.spawner.Teachers.Dequeue();
        }
        manager.spawner.Teachers.Enqueue(learnFrom);

        foreach (GOAPAct act in learnFrom.availableActions)
        {
            if (!IsDupeAction(act))
            {
                availableActions.Add(act.Clone());
            }
        }

        //learn one more random action from a random AI just to keep it spicy
        int           teacher      = UnityEngine.Random.Range(0, manager.spawner.ActiveBuddies.Count);
        CreatureLogic randoTeacher = manager.spawner.ActiveBuddies[teacher].GetComponent <CreatureLogic>();

        if (randoTeacher != null && randoTeacher.availableActions.Count > 0)
        {
            GOAPAct a = randoTeacher.availableActions[UnityEngine.Random.Range(0, randoTeacher.availableActions.Count)];
            availableActions.Add(a);
        }
        else
        {
            LearnRandomSkills();
            return;
        }
        SetGoals();
    }
示例#2
0
 // The AI attacking with one of their played creatures
 bool Attack()
 {
     // For all the creatures this AI has got on the table
     foreach (CreatureLogic creature in thisAI.table.CreaturesOnTable)
     {
         if (creature.AttacksLeftThisTurn > 0)
         {
             // Check if there's any creatures on the players side of the board
             if (thisAI.otherPlayer.table.CreaturesOnTable.Count > 0)
             {
                 int           randomPicker = Random.Range(0, thisAI.otherPlayer.table.CreaturesOnTable.Count);
                 CreatureLogic chosenEnemy  = thisAI.otherPlayer.table.CreaturesOnTable[randomPicker];
                 creature.AttackCreature(chosenEnemy);
             }
             else
             {
                 creature.GoFace();
             }
             // Has attacked something
             return(true);
         }
     }
     // Couldn't attack
     return(false);
 }
示例#3
0
        public static Npc CreateNpc(SpawnTemplate spawnTemplate)
        {
            NpcTemplate npcTemplate = (Data.Data.NpcTemplates.ContainsKey(spawnTemplate.NpcId))
                ? Data.Data.NpcTemplates[spawnTemplate.NpcId]
                : new NpcTemplate();

            var npc = new Npc
            {
                NpcId         = spawnTemplate.NpcId,
                SpawnTemplate = spawnTemplate,
                NpcTemplate   = npcTemplate,

                Position = new WorldPosition
                {
                    MapId = spawnTemplate.MapId,
                    X     = spawnTemplate.X,
                    Y     = spawnTemplate.Y,
                    Z     = spawnTemplate.Z,
                },
            };

            npc.BindPoint = npc.Position.Clone();

            npc.GameStats = CreatureLogic.InitGameStats(npc);
            CreatureLogic.UpdateCreatureStats(npc);

            AiLogic.InitAi(npc);

            return(npc);
        }
示例#4
0
    public void SummonACreature(CardLogic cardLogic, Tile tile)
    {
        // Withdraw from Players Resources
        manaCount  -= cardLogic.currentManaCost;
        bloodCount -= cardLogic.currentBloodCost;
        earthCount -= cardLogic.currentEarthCost;
        // Update visual player resources
        playerVisual.resourcesVisual.SetResourcesVisual(manaCount, bloodCount, earthCount);

        // Create CreatureLogic and add it to the table.
        CreatureLogic newCreature = new CreatureLogic(this, cardLogic.cardAsset);

        // Add the CreatureLogic to the table Logic at the tile.
        Table.instance.AddCreatureToTile(newCreature, tile);

        new SummonACreatureCommand(cardLogic, this, tile, newCreature.uniqueCreatureID).AddToQueue();

        if (newCreature.effect != null)
        {
            // newCreature.effect.WhenACreatureIsPlayed();
        }

        playerState      = PlayerState.Idle;
        cardToBeSummoned = null;
    }
示例#5
0
    bool AttackWithACreature()
    {
        foreach (CreatureLogic cl in p.table.CreaturesOnTable)
        {
            if (cl.AttacksLeftThisTurn > 0)
            {
                // atakuj losowy cel ze stworami
                if (p.otherPlayer.table.CreaturesOnTable.Count > 0)
                {
                    int           index          = Random.Range(0, p.otherPlayer.table.CreaturesOnTable.Count);
                    CreatureLogic targetCreature = p.otherPlayer.table.CreaturesOnTable[index];
                    cl.AttackCreature(targetCreature);
                }
                else
                {
                    cl.GoFace();
                }

                InsertDelay(1f);
                //Debug.Log("AI zaatakowało stworzenie");
                return(true);
            }
        }
        return(false);
    }
示例#6
0
    bool AttackWithACreature()
    {
        foreach (CreatureLogic cl in p.table.CreaturesOnTable)
        {
            if (cl.AttacksLeftThisTurn > 0)
            {
                // attack a random target with a creature
                if (p.otherPlayer.table.CreaturesOnTable.Count > 0)
                {
                    CreatureLogic targetCreature = p.otherPlayer.table.CreaturesOnTable.OrderBy(c => c.Attack).First();
                    cl.AttackCreature(targetCreature);
                }
                else
                {
                    cl.GoFace();
                }

                InsertDelay(1f);
                //Debug.Log("AI attacked with creature");
                return(true);
            }
        }
        TurnManager.Instance.EndTurn();
        return(false);
    }
示例#7
0
文件: MapService.cs 项目: tbs005/Temu
        public static Npc CreateNpc(SpawnTemplate spawnTemplate)
        {
            var npc = new Npc
            {
                NpcId         = spawnTemplate.NpcId,
                SpawnTemplate = spawnTemplate,
                NpcTemplate   = Data.Data.NpcTemplates[spawnTemplate.Type][spawnTemplate.NpcId],

                Position = new WorldPosition
                {
                    MapId = spawnTemplate.MapId,
                    X     = spawnTemplate.X,
                    Y     = spawnTemplate.Y,
                    Z     =
                        spawnTemplate.Z +
                        ((spawnTemplate.FullId == 6301151 ||
                          spawnTemplate.FullId == 6301152 ||
                          spawnTemplate.FullId == 6301153)
                             ? 0
                             : 25),
                    Heading = spawnTemplate.Heading,
                }
            };

            npc.BindPoint = npc.Position.Clone();

            npc.GameStats = CreatureLogic.InitGameStats(npc);
            CreatureLogic.UpdateCreatureStats(npc);

            AiLogic.InitAi(npc);

            return(npc);
        }
示例#8
0
    public void AttackCreature(CreatureLogic target)
    {
        bool targetTaunt = target.ca.Taunt;

        // Can't attack targets without taunt if taunt creature is present
        if (!targetTaunt)
        {
            foreach (CreatureLogic oppCreature in owner.otherPlayer.table.CreaturesOnTable)
            {
                if (oppCreature.ca.Taunt)
                {
                    Debug.Log("Can't attack, taunt creature present on table");
                    return; //no attack happens
                }
            }
            ;
        }
        AttacksLeftThisTurn--;
        // calculate the values so that the creature does not fire the DIE command before the Attack command is sent
        int targetHealthAfter   = target.Health - Attack;
        int attackerHealthAfter = Health - target.Attack;

        new CreatureAttackCommand(target.UniqueCreatureID, UniqueCreatureID, target.Attack, Attack, attackerHealthAfter, targetHealthAfter).AddToQueue();

        target.Health -= Attack;
        Health        -= target.Attack;
    }
示例#9
0
    public void ChangePlayer(CreatureLogic newPlayer)
    {
        if (newPlayer.gameObject.layer == 9)
        {
            Vector3 offset = newPlayer.MyPosition;

            _manager.player = newPlayer.gameObject;
            _manager.move.SetNewTarget(newPlayer.transform);
            foreach (GameObject member in PartyMembers)
            {
                CreatureLogic memberLogic = member.GetComponent <CreatureLogic>();
                memberLogic.MyPosition -= offset;
                memberLogic.SetPartner();
                member.layer = 9;
            }
            newPlayer._player          = true;
            newPlayer._party           = false;
            newPlayer.gameObject.layer = 8;

            foreach (DropListener panel in _grid)
            {
                panel.MyPosition -= offset;
            }
        }
        else
        {
            Debug.Log("invalid click: " + newPlayer.name);
        }
    }
示例#10
0
    /// <summary>
    /// WARNING: The param specialAmount is f****d up, and must follow special conventions. <para/>
    /// It must be a 4 digit postive number. <para/>
    /// 1st digit: Sign digit for attack change. 0: -ve, 1: +ve <para/>
    /// 2nd digit: Magnitude for attack change (0-9) <para/>
    /// 3rd digit: Sign digit for health change. 0: -ve, 1: +ve <para/>
    /// 4th digit: Magnitude for health change (0-9) <para/>
    /// Example: 213 (read as 0213) means +2/-3
    /// </summary>
    public override void ActivateEffect(int specialAmount = 0, ICharacter target = null)
    {
        CreatureLogic creature        = (CreatureLogic)target;
        bool          attackSign      = (specialAmount / 1000 % 10) != 0;
        int           attackMagnitude = (specialAmount / 100 % 10);
        bool          healthSign      = (specialAmount / 10 % 10) != 0;
        int           healthMagnitude = (specialAmount / 1 % 10);

        int attackAmount = attackMagnitude;

        if (attackSign)
        {
            attackAmount = -attackAmount;
        }
        int healthAmount = healthMagnitude;

        if (healthSign)
        {
            healthAmount = -healthAmount;
        }

        new ChangeStatsCommand(creature.ID, attackAmount, healthAmount,
                               creature.Attack + attackAmount, creature.Health + healthAmount).AddToQueue();
        creature.Attack    += attackAmount;
        creature.MaxHealth += healthAmount;
    }
示例#11
0
 public void AddToParty(CreatureLogic who)
 {
     who.SetPartner();
     AssignPartyPosition(who);
     PartyMembers.Add(who.gameObject);
     _manager.ui.AddFaceToGrid(who.MyGridFace);
 }
示例#12
0
    void AssignPartyPosition(CreatureLogic who)
    {
        Vector3 pos = _gridStack.Pop();

        who.SetPosition(pos);
        GridSpaces.Remove(pos);
    }
示例#13
0
    bool AttackWithACreature()
    {
        foreach (CreatureLogic cl in p.table.CreaturesOnTable)
        {
            if (cl.AttacksLeftThisTurn > 0)
            {
                // attack a random target with a creature
                if (p.otherPlayer.table.CreaturesOnTable.Count > 0)
                {
                    int           index          = Random.Range(0, p.otherPlayer.table.CreaturesOnTable.Count);
                    CreatureLogic targetCreature = p.otherPlayer.table.CreaturesOnTable[index];
                    cl.AttackCreature(targetCreature);
                }
                else
                {
                    cl.GoFace();
                }

                InsertDelay(1f);
                //Debug.Log("AI attacked with creature");
                return(true);
            }
        }
        return(false);
    }
示例#14
0
 public CreatureEffect(Player owner, CreatureLogic creature, int specialAmount, string specialName)
 {
     this.creature      = creature;
     this.owner         = owner;
     this.specialAmount = specialAmount;
     this.specialName   = specialName;
 }
示例#15
0
    // 2nd overload - by logic units
    public void PlayACreatureFromHand(CardLogic playedCard, int tablePos)
    {
        // Debug.Log(ManaLeft);
        // Debug.Log(playedCard.CurrentManaCost);
        ManaLeft -= playedCard.CurrentManaCost;
        // Debug.Log("Mana Left after played a creature: " + ManaLeft);
        // create a new creature object and add it to Table
        CreatureLogic newCreature = new CreatureLogic(this, playedCard.ca);

        table.CreaturesOnTable.Insert(tablePos, newCreature);
        //
        new PlayACreatureCommand(playedCard, this, tablePos, newCreature.UniqueCreatureID).AddToQueue();
        // cause battlecry Effect
        if (newCreature.effect != null)
        {
            newCreature.effect.WhenACreatureIsPlayed();
        }

        if (playedCard.ca.soundPlay)
        {
            Vector3 position = new Vector3();
            position.z = -14;
            AudioSource.PlayClipAtPoint(playedCard.ca.soundPlay, position);
        }

        // remove this card from hand
        hand.CardsInHand.Remove(playedCard);
        HighlightPlayableCards();
    }
示例#16
0
        protected void Regenerate()
        {
            switch (Player.PlayerData.Class)
            {
            default:
                int regenRate = 100;
                switch (Player.PlayerMode)
                {
                case PlayerMode.Relax: regenRate = 10; break;

                case PlayerMode.Normal: regenRate = 80; break;

                case PlayerMode.Armored: regenRate = 140; break;
                }

                if (Player.LifeStats.Hp < Player.MaxHp)
                {
                    CreatureLogic.HpChanged(Player, Player.LifeStats.PlusHp(Player.MaxHp / regenRate));
                }

                if (Player.LifeStats.Mp < Player.MaxMp)
                {
                    CreatureLogic.MpChanged(Player, Player.LifeStats.PlusMp(Player.MaxMp * Player.GameStats.NaturalMpRegen / regenRate));
                }
                break;
            }
        }
示例#17
0
    // attack specific creature
    public void AttackCreatureWithID(int uniqueCreatureID)
    {
        // get creatures ID
        CreatureLogic target = CreatureLogic.CreaturesCreatedThisGame[uniqueCreatureID];

        AttackCreature(target); // attack it
    }
示例#18
0
 void Attack()
 {
     _attackCounter += Time.deltaTime;
     if (_attackCounter > _attackTimer)
     {
         _attackCounter = 0;
         CreatureLogic targetLogic = _attackTarget.GetComponent <CreatureLogic>();
         if (targetLogic.Health <= 0 || _attackTarget.gameObject.activeSelf == false) //if target ain't dead
         {
             _attackTarget = null;                                                    //he's dead jim!
         }
         else if (gameObject.activeSelf == true)                                      //if im alive
         {
             if (MyType == CharacterType.Melee)
             {
                 MeleeAttack();
             }
             else if (MyType == CharacterType.Range)
             {
                 RangeAttack();
             }
             else if (MyType == CharacterType.Tech)
             {
                 TechAttack();
             }
         }
     }
 }
示例#19
0
        protected void Regenerate()
        {
            if (UsedCampfire != null)
            {
                CreatureLogic.StaminaChanged(Player, Player.LifeStats.PlusStamina(UsedCampfire.Type == 4 ? 2 : 1));
            }

            if (Player.LifeStats.Hp < Player.MaxHp)
            {
                CreatureLogic.HpChanged(Player, Player.LifeStats.PlusHp(UsedCampfire != null
                                                                            ? Player.MaxHp / 100
                                                                            : Player.MaxHp / 200));
            }

            switch (Player.PlayerData.Class)
            {
            case PlayerClass.Slayer:
            case PlayerClass.Berserker:
                if (LastBattleUts + 5000 < RandomUtilities.GetCurrentMilliseconds() && Player.LifeStats.Mp > 0)
                {
                    CreatureLogic.MpChanged(Player, Player.LifeStats.MinusMp(Player.MaxHp / 90));
                }
                break;

            default:
                if (Player.LifeStats.Mp < Player.MaxMp)
                {
                    CreatureLogic.MpChanged(Player, Player.LifeStats.PlusMp(UsedCampfire != null
                                                                            ? Player.MaxMp * Player.GameStats.NaturalMpRegen / 350
                                                                            : Player.MaxMp * Player.GameStats.NaturalMpRegen / 700));
                }
                break;
            }
        }
示例#20
0
    public void Move(CreatureLogic creatureLogic, List <Tile> currentPath)
    {
        if (creatureLogic.creatureState == CreatureState.Idle)
        {
            if (currentPath != null)
            {
                DrawPath(currentPath);
                Table.instance.RemoveCreatureFromTile(creatureLogic.currentTile);
                Table.instance.AddCreatureToTile(creatureLogic, currentPath[currentPath.Count - 1]);
                creatureLogic.creatureState = CreatureState.Moving;

                Sequence moveSequence = DOTween.Sequence();
                int      currNode     = 1;
                while (currNode < currentPath.Count)
                {
                    Vector3 currentTarget = currentPath[currNode].transform.position;
                    moveSequence.Append(transform.DOMove(currentTarget, 1));

                    currNode++;
                }

                moveSequence.Play();
                moveSequence.OnComplete(() => {
                    creatureLogic.currentTile   = currentPath[currentPath.Count - 1];
                    creatureLogic.creatureState = CreatureState.Idle;
                    _lineRenderer.enabled       = false;
                });
            }
        }
    }
示例#21
0
        public void Start(Player player)
        {
            Player = player;

            player.PlayerMode = PlayerMode.Armored;

            CreatureLogic.UpdateCreatureStats(Player);
        }
示例#22
0
    public FaceDisplay CreateGridFace(float[] face, CreatureLogic who)
    {
        FaceDisplay newFace = Instantiate(_gridFacePrefab, Vector3.zero, Quaternion.identity, _defaultGridSpot) as FaceDisplay;

        newFace.DisplayFace(face);
        newFace.GetComponent <DragDrop>().MyCreature = who;
        newFace.gameObject.SetActive(false);
        return(newFace);
    }
示例#23
0
        public void InitPlayer(Player player)
        {
            player.GameStats = CreatureLogic.InitGameStats(player);
            CreatureLogic.UpdateCreatureStats(player);

            AiLogic.InitAi(player);

            PlayersOnline.Add(player);
        }
示例#24
0
        protected void Distress()
        {
            if (Player.LifeStats.Stamina <= 0 || UsedCampfire != null)
            {
                return;
            }

            CreatureLogic.StaminaChanged(Player, Player.LifeStats.MinusStamina(1));
        }
示例#25
0
    public void PlaySpellFromHand(int spellCardId, int targetId)
    {
        var characterTarget = targetId < 0 ? null as ICharacter :
                              targetId == ID ? this as ICharacter :
                              targetId == OtherPlayer.ID ? OtherPlayer as ICharacter :
                              CreatureLogic.FindCreatureLogicById(targetId) as ICharacter;

        PlaySpellFromHand(spellCardId, characterTarget);
    }
示例#26
0
    void InitializeFirstPlayer()
    {
        CreatureLogic playerLogic = player.GetComponent <CreatureLogic>();

        playerLogic.SetCreature(player.transform.position, false);
        PartyManager.PartyMembers.Add(player);
        move.SetNewTarget(initialPlayer);
        ui.AddFaceToGrid(playerLogic.MyGridFace);
    }
示例#27
0
        public void Start(Player player)
        {
            Player = player;

            player.PlayerMode = PlayerMode.Armored;

            Global.VisibleService.Send(Player, new SpCharacterState(player));
            PassivityProcessor.OnBattleEnter(player);
            CreatureLogic.UpdateCreatureStats(Player);
        }
示例#28
0
    public void AttackCreature(CreatureLogic target)
    {
        AttacksLeftThisTurn--;
        int targetHealthAfter   = target.Health - Attack;
        int attackerHealthAfter = Health - target.Attack;

        new CreatureAttackCommand(target.UniqueCreatureID, UniqueCreatureID, target.Attack, Attack, attackerHealthAfter, targetHealthAfter).AddToQueue();
        target.Health -= Attack;
        Health        -= target.Attack;
    }
示例#29
0
 public void SetChild(CreatureLogic faja, CreatureLogic maja)
 {
     Strength = Mathf.Max(faja.Strength, maja.Strength) * Random.Range(.8f, 1.2f);
     Speed    = Mathf.Max(faja.Speed, maja.Speed) * Random.Range(.8f, 1.2f);
     Range    = Mathf.Max(faja.Range, maja.Range) * Random.Range(.8f, 1.2f);
     Tech     = Mathf.Max(faja.Tech, maja.Tech) * Random.Range(.8f, 1.2f);
     Heal     = Mathf.Max(faja.Heal, maja.Heal) * Random.Range(.8f, 1.2f);
     SetStats(true);
     SetPlayer();
 }
示例#30
0
    void optimize(CreatureLogic creature)
    {
        int attackAmount = creature.Attack;
        int healthAmount = 1 - creature.Health;

        new ChangeStatsCommand(creature.ID, attackAmount, healthAmount,
                               creature.Attack + attackAmount, creature.Health + healthAmount).AddToQueue();
        creature.Attack    += attackAmount;
        creature.MaxHealth += healthAmount;
    }