Exemplo n.º 1
0
	// Use this for initialization
    public csBot(int level) 
    {

        Texture2D avatar = (Texture2D)Resources.Load("Sprites/Avatars/Adventure Avatar");
        Sprite sprite = Sprite.Create(avatar, new Rect(0, 0, avatar.width, avatar.height), new Vector2(.5f, .5f), 100);
        avatars.Add(sprite);
        avatar = (Texture2D)Resources.Load("Sprites/Avatars/Knight Avatar");
        sprite = Sprite.Create(avatar, new Rect(0, 0, avatar.width, avatar.height), new Vector2(.5f, .5f), 100);
        avatars.Add(sprite);
        avatar = (Texture2D)Resources.Load("Sprites/Avatars/Ninja Avatar");
        sprite = Sprite.Create(avatar, new Rect(0, 0, avatar.width, avatar.height), new Vector2(.5f, .5f), 100);
        avatars.Add(sprite);
        avatar = (Texture2D)Resources.Load("Sprites/Avatars/Ninja Man Avatar");
        sprite = Sprite.Create(avatar, new Rect(0, 0, avatar.width, avatar.height), new Vector2(.5f, .5f), 100);
        avatars.Add(sprite);
        

        var idx = Random.Range(0, avatars.Count);
        Avatar = avatars[idx];

        float points = 0;
        Level = level;

        var percentage = GetRandomPercentage(3);
        levelPoints = (Level - 1) * 50;

        points = (percentage[0] / 100) * levelPoints;
        var strengthPoints = Mathf.FloorToInt(float.Parse(points.ToString()));
        Strength = 100 + strengthPoints;
        currLevelPoints += strengthPoints;

        points = (percentage[1] / 100) * levelPoints;
        var dexterityPoints = Mathf.FloorToInt(float.Parse(points.ToString()));
        Dexterity = 100 + dexterityPoints;
        currLevelPoints += dexterityPoints;

        var inteligencePoints = Mathf.FloorToInt(levelPoints - currLevelPoints);
        Intelligence = 100 + inteligencePoints;

        Hitpoints = Strength;
        Stamina = Dexterity;
        Mana = Intelligence;

        var exampleNames = GetExampleNames();
        var nameGenerator = new csNameGenerator(exampleNames, 0, 4);

        nameGenerator.Reset();
        Name = nameGenerator.NextName;

        InitPowers();
        InitWeaknesses();
        InitMagicalDefences();
        InitPhysicalAttacks();
        InitPhysicalDefences();

        Weaknesses = new List<csWeakness>();
        Weaknesses.Add(GetRandomWeakness());
        var weakness = GetRandomWeakness();
        if (Weaknesses.Count > 0)
        {
            var result = Weaknesses.FirstOrDefault(s => s.Weakness == weakness.Weakness);
            if (result != null)
            {
                Weaknesses.Remove(result);
                weakness.Multiplier++;
            }
        }
        Weaknesses.Add(weakness);

        Powers = new List<csMagicPower>();
        Powers.Add(GetRandomPower());

        MagicalDefense = new List<csMagicDefense>();
        MagicalDefense.Add(GetRandomMagicalDefense());

        foreach (var attack in Attacks)
        {
            attack.CasterLevel = Level;
            attack.BaseStatus = Strength;
        }

        var meditation = new csPassivePower()
        {
            Factor = 0.01f,
            Name = "Meditation",
            CasterLevel = Level,
            BaseStatus = Intelligence,
            Value = 1.0f
        };
        meditation.Init();

        PassivePower = new List<csPassivePower>();
        PassivePower.Add(meditation);
	}
Exemplo n.º 2
0
    public void Init()
    {
        if (csGameController.control.LastTime == DateTime.MinValue)
        {
            Name = "Asghard";
            Level = 1;
            MaxLevel = Level * levelFactor;
            Avatar = avatar;
            IsAwake = true;

            Experience = 0;

            Strength = 100;
            Dexterity = 100;
            Intelligence = 100;

            Hitpoints = Strength;
            Stamina = Dexterity;
            Mana = Intelligence;

            MaxHealth = 100;
            MaxHappiness = 100;
            MaxEnergy = 100;
            MaxFood = 100;

            Health = MaxHealth;
            OverallHealth = MaxHealth;
            Happiness = MaxHappiness;
            OverallHappiness = MaxHappiness;
            Energy = MaxEnergy;
            OverallEnergy = MaxEnergy;
            Food = MaxFood;
            OverallFood = MaxFood;

            Generation = 1;
            Breeds = 0;
            MaxBreeds = 3;
            Fame = 0;
            Deceases = 0;
            Resistance = 20;
            Rarity = 1;

            CurrentStage = csLifeStagesEnum.Baby;

            csSkill cooking = new csSkill()
            {
                Name = "Cooking",
                Max = 100.0f,
                Min = 0.0f,
                Value = 0.0f,
                Factor = 0.01f
            };

            if(!skillsDict.ContainsKey(csSkillEnum.Cooking))
                skillsDict.Add(csSkillEnum.Cooking, cooking);

            csSkill medicine = new csSkill()
            {
                Name = "Medicine",
                Max = 100.0f,
                Min = 0.0f,
                Value = 0.0f,
                Factor = 0.01f
            };

            if (!skillsDict.ContainsKey(csSkillEnum.Medicine))
                skillsDict.Add(csSkillEnum.Medicine, medicine);

            csSkill science = new csSkill()
            {
                Name = "Science",
                Max = 100.0f,
                Min = 0.0f,
                Value = 0.0f,
                Factor = 0.01f
            };

            if (!skillsDict.ContainsKey(csSkillEnum.Science))
                skillsDict.Add(csSkillEnum.Science, science);

            csSkill tailoring = new csSkill()
            {
                Name = "Tailoring",
                Max = 100.0f,
                Min = 0.0f,
                Value = 0.0f,
                Factor = 0.01f
            };

            if (!skillsDict.ContainsKey(csSkillEnum.Tailoring))
                skillsDict.Add(csSkillEnum.Tailoring, tailoring);

            message = GameObject.FindObjectOfType<csMessageManager>();

            InitPowers();
            InitWeaknesses();
            InitMagicalDefences();
            InitPhysicalAttacks();
            InitPhysicalDefences();

            Weaknesses = new List<csWeakness>();
            Weaknesses.Add(GetRandomWeakness());
            var weakness = GetRandomWeakness();
            if(Weaknesses.Count > 0)
            {
                var result = Weaknesses.FirstOrDefault(s => s.Weakness == weakness.Weakness);
                if (result != null)
                {
                    Weaknesses.Remove(result);
                    weakness.Multiplier++;
                }
            }
            Weaknesses.Add(weakness);

            Powers = new List<csMagicPower>();
            var power = GetRandomPower();
            Powers.Add(power);

            MagicalDefense = new List<csMagicDefense>();
            MagicalDefense.Add(GetRandomMagicalDefense());

            var meditation = new csPassivePower()
            {
                Factor = 0.01f,
                Name = "Meditation",
                CasterLevel = Level,
                BaseStatus = Intelligence,
                Value = 1.0f
            };
            meditation.Init();

            PassivePower = new List<csPassivePower>();
            PassivePower.Add(meditation);

            Knowledge = new List<csMagicDefense>();

            CancelInvoke("FoodManagement");
            InvokeRepeating("FoodManagement", 0, 1.0f);
            CancelInvoke("HappinessManagment");
            InvokeRepeating("HappinessManagment", 0, 1.0f);
            CancelInvoke("EnergyManagment");
            InvokeRepeating("EnergyManagment", 0, 1.0f);
            CancelInvoke("HealthManagment");
            InvokeRepeating("HealthManagment", 0, 1.0f);
        }
    }