コード例 #1
0
ファイル: MapGenerator.cs プロジェクト: SuperPaw/Goblin-Game
    private IEnumerator LootGenRoutine()
    {
        //ADDING LOOT
        for (int i = 0; i < amountOfLoot; i++)
        {
            var parentArea = GetRandomArea();

            //TODO: should only be in area
            Tile tile = GetRandomGroundTile(parentArea);

            tile.Type = TileType.Loot;
            movableTiles.Remove(tile);

            var loot = Instantiate(LootObjects[Random.Range(0, LootObjects.Length)]);

            loot.name = "Lootable";

            loot.transform.position = new Vector3(tile.X, 1, tile.Y);

            loot.transform.parent = parentArea.transform;
            var l = loot.GetComponent <Lootable>();

            parentArea.Lootables.Add(l);
            parentArea.MovablePositions.Remove(tile);

            l.InArea = parentArea;

            if (EquipmentInLootChance > Random.value)
            {
                l.EquipmentLoot.Add(EquipmentGen.GetRandomEquipment());
            }

            int loc = (++progress * 100) / totalProgress;
            if (loc != progressPct)
            {
                progressPct = loc;
                yield return(null);

                progressCallback(progressPct, "Hiding goblin treasures...");
            }
        }


        Debug.Log("Finished Loot gen : " + (Time.time - startTime) + " seconds");
    }
コード例 #2
0
    //TODO: create likely stat associations for types. Like damage -> weapon.

    private void Awake()
    {
        if (!Instance)
        {
            Instance = this;
        }

        //TODO: check that all types are covered

        //for (int i = 0; i < 20; i++)
        //{
        //    var e = GetRandomEquipment();
        //    Debug.Log(e.name + " ; " + e.EquipLocation);
        //    //foreach (var fx in e.Effects)
        //    //{
        //    //    Debug.Log(fx.Stat + " : " + fx.Modifier.Name + " : " + fx.Modifier.Modifier);
        //    //}
        //}
    }
コード例 #3
0
ファイル: WitchHut.cs プロジェクト: SuperPaw/Goblin-Game
    public void BuySkull(int amount, PlayerTeam team)
    {
        team.OnEquipmentFound.Invoke(EquipmentGen.GetEquipment(Equipment.EquipmentType.Skull), team.Leader);

        team.OnTreasureFound.Invoke(-amount);
    }
コード例 #4
0
    public void Awake()
    {
        //if(!Voice)
        //    Voice = GetComponentInChildren<AudioSource>();
        if (Voice)
        {
            VoicePitch = Random.Range(PitchMin, PitchMax);

            if (CharacterRace == Race.Zombie)
            {
                VoicePitch /= 2;
            }

            Voice.pitch = VoicePitch;
        }

        if (!HealtBar)
        {
            HealtBar = GetComponentInChildren <HealtBar>();
        }

        for (int i = 0; i < (int)Equipment.EquipLocations.COUNT; i++)
        {
            Equipped.Add((Equipment.EquipLocations)i, null);
        }


        if (HasEquipment)
        {
            Equip(EquipmentGen.GetRandomEquipment());
        }

        //------------------------- STAT SET-UP --------------------------
        DMG   = new Stat(StatType.DAMAGE, Random.Range(DamMin, DamMax));
        AIM   = new Stat(StatType.AIM, Random.Range(AimMin, AimMax));
        COU   = new Stat(StatType.COURAGE, Random.Range(CouMin, CouMax));
        SPE   = new Stat(StatType.SPEED, Random.Range(SpeMin, SpeMax));
        SMA   = new Stat(StatType.SMARTS, Random.Range(SmaMin, SmaMax));
        Stats = new List <Stat>()
        {
            DMG, AIM, COU, SMA
        }.ToDictionary(s => s.Type);

        //Health is a special case
        HEA    = new Stat(StatType.HEALTH, Random.Range(HeaMin, HeaMax));
        Health = HEA.GetStatMax();

        Material = GetComponentInChildren <Renderer>().material;
        if (Material && Material.HasProperty("_Color"))
        {
            NormalColor = Material.color;
        }
        DamageColor = Color.red;

        OnDamage.AddListener(x => StartCoroutine(HurtRoutine()));
        OnDeath.AddListener(Die);
        OnDeath.AddListener(c => OnAnyCharacterDeath.Invoke(c.CharacterRace));

        AttackRange = transform.lossyScale.x * 2f;

        OnTargetDeath.AddListener(TargetGone);
        OnBeingAttacked.AddListener(BeingAttacked);
        OnCharacterCharacter.AddListener(AttackCharacter);

        if (!navMeshAgent)
        {
            navMeshAgent = GetComponentInChildren <NavMeshAgent>();
        }

        //navMeshAgent.speed = SPE.GetStatMax() /2f; Set in fixedupdate
        Morale = COU.GetStatMax() * 2;

        if (!navMeshAgent)
        {
            Debug.LogWarning(name + ": character does not have Nav Mesh Agent");
        }
    }