public CreatureStats(CreatureStats other)
 {
     this.hp  = other.hp;
     this.str = other.str;
     this.arm = other.arm;
     this.spd = other.spd;
 }
Esempio n. 2
0
        private void HandleAttack(CreatureStats attacker, CreatureStats target, Damage damagedone)
        {
            Direction directionUp;
            Direction directionDown;

            if (attacker.OwnedBy == Owner.PLAYER)
            {
                directionDown = Direction.DOWNRIGHT;
                directionUp   = Direction.UPRIGHT;
            }
            else
            {
                directionDown = Direction.DOWNLEFT;
                directionUp   = Direction.UPLEFT;
            }

            CreatureStats enemyUp   = CombatManager.GetCreatureAt(attacker.GridPosition.InDirection(directionUp));
            CreatureStats enemyDown = CombatManager.GetCreatureAt(attacker.GridPosition.InDirection(directionDown));

            if (enemyDown)
            {
                enemyDown.TakeDamage(new Source(attacker, null), new Damage((int)Mathf.Round(damagedone.Value * 0.5f), DamageType.Physical));
            }
            if (enemyUp)
            {
                enemyUp.TakeDamage(new Source(attacker, null), new Damage((int)Mathf.Round(damagedone.Value * 0.5f), DamageType.Physical));
            }
        }
Esempio n. 3
0
    /// <summary>
    /// Moves the permanent based on its movement stats
    /// </summary>
    /// <param name="permanent">Permanent to make move</param>
    private static void Move(CreatureStats permanent)
    {
        MapPosition from = permanent.GridPosition;

        permanentMap[permanent.GridPosition.x, permanent.GridPosition.y] = null;

        MapPosition to = permanent.GetForward();

        permanentMap[to.x, to.y] = permanent;
        permanent.GridPosition   = to;

        permanent.GetComponent <Animator>().SetBool("IsWalking", true);

        // Move it and set animating state
        LeanTween.move(permanent.gameObject, GridToWorld(to), AnimationMoveDuration).
        setOnComplete(() =>
        {
            if (!permanent)
            {
                return;
            }
            permanent.GetComponent <Animator>().SetBool("IsWalking", false);
        });

        StateManager.RegisterAnimation(AnimationMoveDuration);
        //permanent.transform.position = GridToWorld(to);

        EventManager.InvokePermanentMoved(permanent, from, to);
    }
Esempio n. 4
0
    public bool CheckAttack(CreatureStats from, CreatureStats to)
    {
        AttackAction action = from.GetComponent <AttackAction>();

        action.Init(to);
        return(action.Check());
    }
Esempio n. 5
0
 private void Instance_OnDeathPlayer(CreatureStats creature, IDamage arg2)
 {
     if (creature == _creature)
     {
         _animator.SetBool("death", true);
     }
 }
Esempio n. 6
0
    private void DamageSystem_OnDeathPlayer(CreatureStats c, IDamage damage)
    {
        _allPlayers.Remove(c);

        c.gameObject.tag   = "DeathPlayer";
        c.gameObject.layer = 2;
        c.GetComponent <CharacterController>().enabled = false;

        //Удаляем все состояния
        ICharacterState[] states = c.GetComponents <ICharacterState>();
        foreach (var state in states)
        {
            Destroy(state);
        }

        if (_currentPlayer == c)
        {
            ChangePlayer();
        }

        //Заплатк адля конца
        if (_allPlayers.FirstOrDefault(x => x.team == 1) == null)
        {
            endPoint.SetActive(true);
        }
    }
Esempio n. 7
0
    // Does a creature's combat turn
    private static void ActPermanent(CreatureStats permanent)
    {
        if (CanAttackAnything(permanent))
        {
            Attack(permanent);
            return;
        }


        if (permanent.CanMove())
        {
            int movesLeft = (int)permanent.Speed;

            for (int i = 0; i < movesLeft; i++)
            {
                if (CanAttackAnything(permanent))
                {
                    Attack(permanent);
                    return;
                }
                CreatureStats inFront = GetCreatureAt(permanent.GetForward());
                if (!inFront)
                {
                    Move(permanent);
                }
            }
        }
    }
Esempio n. 8
0
 // Start is called before the first frame update
 private void Awake()
 {
     Parasyte_Stats = FindObjectOfType <PlayerStats>();
     Creature_Image = GetComponentsInChildren <SpriteRenderer>();
     CStats         = GetComponent <CreatureStats>();
     C_man          = GetComponent <CManager>();
 }
Esempio n. 9
0
    // Start is called before the first frame update
    void Start()
    {
        _memory             = GetComponent <CreatureMemory>();
        _statRates          = GetComponent <StatChangeRates>();
        _brain              = GetComponent <Brain>();
        _creatureStatistics = GetComponent <CreatureStatistics>();
        if (_creatureStatistics != null)
        {
            _creatureStats.Health      = _creatureStatistics.maxHealth;
            _creatureStats.Stamina     = _creatureStatistics.maxStamina;
            _creatureStats.Energy      = _creatureStatistics.maxEnergy;
            _creatureStats.Food        = _creatureStatistics.maxFood;
            _creatureStats.Water       = _creatureStatistics.maxWater;
            _creatureStats.Strength    = _creatureStatistics.maxStrength;
            _creatureStats.Fortitude   = _creatureStatistics.maxFortitude;
            _creatureStats.Torpidity   = _creatureStatistics.maxTorpidity;
            _creatureStats.AttackRate  = _creatureStatistics.attackRate;
            _creatureStats.AttackReach = _creatureStatistics.attackReach;
            _creatureStats.Mass        = _creatureStatistics.maxMass;
            _creatureStats.BiteSize    = _creatureStatistics.biteSize;
        }
        _statAlerts = GetComponent <CreatureAlerts>();

        _creatureLiveStats = _creatureStats;
    }
Esempio n. 10
0
 private void MatchSystem_OnChangePlayer(CreatureStats creature)
 {
     /*if (creature == _creature)
      * {
      *  Run();
      * }*/
 }
Esempio n. 11
0
 private void MatchSystem_OnChangePlayer(CreatureStats obj)
 {
     if (CheckInputPlayer(obj))
     {
         EnableSystem(GetComponent <DefaultInputSystem>());
     }
 }
Esempio n. 12
0
        public void takeDamageTest()
        {
            // Create a Hero and an Enemy
            CreatureStats heroStats = new CreatureStats(100, 10, 10, 0);
            Hero          hero      = new Hero("HENK :D", heroStats);

            CreatureStats enemyStats = new CreatureStats(100, 5, 5, 0);
            Enemy         enemy      = new Enemy("KEES D:", enemyStats);

            // Do a bunch of damaging and check if the values are correct
            hero.takeDamage(15);
            enemy.takeDamage(99);

            Assert.IsFalse(hero.IsDead, "Hero has " + hero.Stats.HP + "HP, but is dead.");
            Assert.IsFalse(enemy.IsDead, "Enemy has " + enemy.Stats.HP + "HP, but is dead.");

            hero.takeDamage(15);

            Assert.AreEqual(hero.Stats.MaxHP - 30, hero.Stats.HP, 0.0F, "Hero didn't take the expected amount of damage.");
            Assert.AreEqual(enemy.Stats.MaxHP - 99, enemy.Stats.HP, 0.0F, "Enemy didn't take the expected amount of damage.");

            hero.takeDamage(69);
            enemy.takeDamage(100);

            Assert.IsFalse(hero.IsDead, "Hero has " + hero.Stats.HP + "HP, but is dead.");
            Assert.IsTrue(enemy.IsDead, "Enemy has " + enemy.Stats.HP + "HP, but is alive.");

            hero.takeDamage(1);

            Assert.IsTrue(hero.IsDead, "Hero has " + hero.Stats.HP + "HP, but is alive.");
        }
Esempio n. 13
0
 private void OnCreatureSpawned(CreatureStats permanent, MapPosition pos)
 {
     if (permanent == ownerStats)
     {
         CheckZoneBonus();
     }
 }
Esempio n. 14
0
    public Inventory(CreatureStats creature, int limit = 2)
    {
        ItemList = new List <IInventoryItem>();

        _creature = creature;
        _limit    = limit;
    }
Esempio n. 15
0
        public static List <LayerPalettePair> BuildDwarfLayers(CreatureStats Stats, Random Random)
        {
            var r = new List <LayerPalettePair>();

            foreach (var layerType in LayerLibrary.EnumerateLayerTypes())
            {
                if (layerType.Fundamental)
                {
                    if (r.Any(l => l.Layer.Type == layerType.Name))
                    {
                        continue;
                    }

                    if (layerType.Gendered && Stats.Gender != Gender.Nonbinary)
                    {
                        r.Add(new LayerPalettePair {
                            Layer = SelectRandomLayer(Stats, Random, layerType.Name, l => l.Names.Contains(Stats.Gender.ToString())), Palette = null
                        });
                    }
                    else
                    {
                        r.Add(new LayerPalettePair {
                            Layer = SelectRandomLayer(Stats, Random, layerType.Name), Palette = null
                        });
                    }
                }
            }

            return(r);
        }
Esempio n. 16
0
 private void Instance_OnDealDamage(CreatureStats creature, IDamage arg2)
 {
     if (creature == _creature && impact != null)
     {
         GameHelper.instance.PlaySoundShot(impact);
     }
 }
Esempio n. 17
0
 private void Instance_OnDeathPlayer(CreatureStats creature, IDamage arg2)
 {
     if (creature == _creature && death != null)
     {
         GameHelper.instance.PlaySoundShot(death);
     }
 }
Esempio n. 18
0
    private void Reproduce()
    {
        CreatureController clone = Instantiate(creature, transform.position + transform.right, transform.rotation).GetComponent <CreatureController>();

        int           mutationChance = Random.Range(0, 10);
        CreatureStats cloneStats     = creatureStats.CloneStats();

        if (mutationChance == 0)
        {
            int mutationIndex = Random.Range(0, 3);

            if (mutationIndex == 0)
            {
                cloneStats.speed += initialStats.speed * 0.05f;
            }
            else if (mutationIndex == 1)
            {
                cloneStats.energy += initialStats.energy * 0.05f;
            }
            else if (mutationIndex == 2)
            {
                cloneStats.senseRadius += initialStats.senseRadius * 0.05f;
            }
        }

        clone.creatureStats = cloneStats;
    }
Esempio n. 19
0
    private void ClickObject_OnClick(ClickObject obj)
    {
        if (_action != null)
        {
            if (obj.isCreature)
            {
                _action.Init(obj.GetComponent <CreatureStats>());
                MatchSystem.instance.RunAction(_action);
                _action = null;
                return;
            }
        }

        if (obj.isCreature)
        {
            CreatureStats creature = obj.GetComponent <CreatureStats>();

            if (_action == null)
            {
                //MatchSystem.instance.RunAction(new AttackAction(null,creature));
            }
        }
        else if (obj.isTreasure)
        {
            Treasure treasure = obj.GetComponent <Treasure>();
            if (_action == null)
            {
                //MatchSystem.instance.RunAction(new PickTreasureAction(null, treasure));
            }
        }
    }
Esempio n. 20
0
    public static CreatureStats Decode(JObject json)
    {
        var result = new CreatureStats()
        {
            fitness        = json[CodingKey.Fitness].ToFloat(),
            simulationTime = json[CodingKey.SimulationTime].ToInt(),
            horizontalDistanceTravelled = json[CodingKey.HorizontalDistance].ToFloat(),
            verticalDistanceTravelled   = json[CodingKey.VerticalDistance].ToFloat(),
            maxJumpingHeight            = json[CodingKey.MaxJumpHeight].ToFloat(),
            weight          = json[CodingKey.Weight].ToFloat(),
            numberOfBones   = json[CodingKey.NumberOfBones].ToInt(),
            numberOfMuscles = json[CodingKey.NumberOfMuscles].ToInt(),
            averageSpeed    = json[CodingKey.AverageSpeed].ToFloat()
        };

        if (json.ContainsKey(CodingKey.UnclampedFitness))
        {
            result.unclampedFitness = json[CodingKey.UnclampedFitness].ToFloat();
        }
        else
        {
            result.unclampedFitness = result.fitness;
        }
        return(result);
    }
Esempio n. 21
0
    //public Animation[] Animations;


    private void Awake()
    {
        Creature_Stats    = GetComponent <CreatureStats>();
        Creature_Movement = GetComponent <CreatureMovement>();
        Hived             = false;
        C_animator        = GetComponentsInChildren <Animator>();
    }
Esempio n. 22
0
    // Moves can learn

    public Species(string _name, ElementTypes[] _types, CreatureStats _stats, Ability[] _abilities)
    {
        name              = _name;
        types             = _types;
        baseStats         = _stats;
        possibleAbilities = _abilities;
    }
Esempio n. 23
0
 private void OnPermanentDestroyed(CreatureStats creature, Source killSource)
 {
     if (killSource.Creature == owner)
     {
         owner.Heal(3);
     }
 }
 private void OnCreatureStartMovement(CreatureStats creature)
 {
     if (creature == owner)
     {
         DoTurn();
     }
 }
Esempio n. 25
0
    public static int calculateDamage(double movePower, CreatureStats sourceCreature, CreatureStats receivingCreature)
    {
        int attackerSTR = sourceCreature.getStat(StatName.STR);
        int defenderARM = receivingCreature.getStat(StatName.ARM);

        return((int)(movePower + (attackerSTR - defenderARM)));
    }
Esempio n. 26
0
    public void SendNotify(CreatureStats creature, IInventoryItem item, float seconds = 3)
    {
        UINotifyNewItem notify = Instantiate <UINotifyNewItem>(NewItemNotifyPrefab, _canvas);

        notify.Init(creature.avatar, item.Icon);
        GameHelper.instance.DelayMethod(() => Destroy(notify.gameObject), seconds);
    }
Esempio n. 27
0
        public List <SceneAnimation> GiveStatBoost(CreatureStats Stat, bool IsPositiveBoost)
        {
            List <SceneAnimation> Animations = new List <SceneAnimation>();

            if (Stat == CreatureStats.HEALTH || Stat == CreatureStats.KIN)
            {
            }
            if (IsPositiveBoost)
            {
                if (Statboosts[Stat] < 10)
                {
                    Statboosts[Stat]++;
                    Animations.Add(new SceneAnimation(SceneAnimation.SceneAnimationType.STAT_BOOST, new double[] { playerNumber, (double)Stat, 1 }, "#STAT BOOST ANIMATION#"));
                    if (AttackGainOnStatBoost.Evaluate() && Stat != CreatureStats.STRENGTH && Stat != CreatureStats.INTELLIGENCE)
                    {
                        Animations.Add(new SceneAnimation(SceneAnimation.SceneAnimationType.ADD_MESSAGE, null, "The Strength of " + ActiveCreature.Nickname + " increased!"));
                        Animations.AddRange(GiveStatBoost(CreatureStats.STRENGTH, true));
                        Animations.AddRange(GiveStatBoost(CreatureStats.STRENGTH, true));
                    }
                }
            }
            else
            {
                if (Statboosts[Stat] > 0)
                {
                    Statboosts[Stat]--;
                    Animations.Add(new SceneAnimation(SceneAnimation.SceneAnimationType.STAT_BOOST, new double[] { playerNumber, (double)Stat, -1 }, "#STAT BOOST ANIMATION#"));
                }
            }

            return(Animations);
        }
    public static Creature fromJSONObject(JSONObject json)
    {
        int           creatureId   = (int)json.GetField("creatureId").n;
        string        creatureName = json.GetField("creatureName").str;
        CreatureStats baseStats    = CreatureStats.fromJSONObject(json.GetField("baseStats"));
        //TODO deserialize Abilities
        Ability        ability = null;
        HashSet <Move> moves   = new HashSet <Move>();

        foreach (JSONObject moveName in json.GetField("moves").list)
        {
            string n = moveName.str;
            moves.Add(MoveLibrary.get(n));
        }
        FocalPoints         focalPoints    = FocalPoints.fromJSONObject(json.GetField("focalPoints"));
        CreatureForm        baseForm       = CreatureForm.fromJSONObject(json.GetField("baseForm"));
        List <CreatureForm> availableForms = new List <CreatureForm>();

        foreach (JSONObject formJSON in json.GetField("availableForms").list)
        {
            CreatureForm creatureForm = CreatureForm.fromJSONObject(formJSON);
            availableForms.Add(CreatureForm.fromJSONObject(formJSON));
        }
        Creature result = new Creature(creatureId, creatureName, moves, focalPoints, ability, baseStats, baseForm, availableForms);

        return(result);
    }
Esempio n. 29
0
        public MenuScreen()
        {
            heroList = new List <Creature>();
            baddudes = new List <Creature>();

            CreatureStats heroStats = new CreatureStats(100, 5, 0.5);

            hero = new Hero("tester", heroStats);

            CreatureStats baddudeStats = new CreatureStats(100, 5, 0.1);

            baddude = new Enemy("tester", baddudeStats);
            baddudes.Add(baddude);
            heroList.Add(hero);
            newBattle = new Battle(heroList, baddudes);
            OngoingBattles.ongoingBattleList.Add(newBattle);

            // Add the Exit button
            GuiButton buttonExit = new GuiButton(new Rectangle(0, 0, 32, 32), "testure");

            buttonExit.ClickHandler = kill;
            addElement(buttonExit);

            // Add an Inventory button
            GuiButton buttonInventory = new GuiButton(new Rectangle(300, 0, 32, 32), "testure");

            buttonInventory.ClickHandler = () => ScreenManager.Instance.selectScreen("inventory");
            addElement(buttonInventory);

            // Set the font
            font = "font";
        }
Esempio n. 30
0
 public void OnPermanentDestroyed(CreatureStats deadCreature, Source killSource)
 {
     if (deadCreature == stats)
     {
         LoseGame();
     }
 }
Esempio n. 31
0
    // =====================================================
    // Initialization
    // =====================================================
    public override void Init(Grid grid, int x, int y, float scale = 1, Sprite asset = null)
    {
        base.Init(grid, x, y, scale, asset);
        walkable = false;

        SetImages(scale, new Vector3(0, 0.1f, 0), 0.035f);

        state = CreatureStates.Idle;
        stats = new CreatureStats();
        bar.Init(this);

        LocateAtCoords(x, y);
    }
Esempio n. 32
0
    public static CreatureStats operator +(CreatureStats first, CreatureStats other)
    {
        CreatureStats temp = new CreatureStats();
        temp._MaxHealth = first.maxHealth + other.maxHealth;
        temp._Size = first.size + other.size;
        temp._MoveSpeed = first.moveSpeed + other.moveSpeed;
        temp._Weight = first.weight + other.weight;
        temp._Armor = first.armor + other.armor;

        return temp;
    }
Esempio n. 33
0
 void UpdateStats()
 {
     CreatureStats statsCalc = new CreatureStats(); ;
     foreach (EquipmentSlot i in _Equipment)
     {
         if (i.equiped != null)
         {
             statsCalc += i.equiped.statsAdded;
         }
     }
     stats = _BaseStats + statsCalc;
 }