- Massive rebalance of all units and levels (game is more focused on early base building and late powerful waves) - Added all desert levels - Added spearman, archer lvl3, gatherers lvl2 and lvl3, temp art skittering husk - Added stone house (more pop) - Tooltip visual rework - Some bugs fixed - Playing sounds when placing units Reviewed-on: http://gitea.clubconjure.com/Conjure/gather-and-defend/pulls/22 Reviewed-by: Ader_Alisma <ader.alisma.1@ens.etsmtl.ca> Co-authored-by: Craftelia <william-gin1@hotmail.com> Co-committed-by: Craftelia <william-gin1@hotmail.com>
57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using UnityEngine;
|
|
using System.Collections.Generic;
|
|
using static Enum;
|
|
|
|
public class Harvester : Ally
|
|
{
|
|
[SerializeField] [Tooltip("helps choose the right skin for the harvester depending on resource")]
|
|
private List<HarvesterResourcePair> _harvesterResourcePairs;
|
|
protected ResourceNodeType ResourceNodeType => _resourceNodeType;
|
|
|
|
public override Vector2 RangeMultiplier { get; }
|
|
|
|
public override float HpMultiplier { get; }
|
|
|
|
public override float SpeedMultiplier { get; }
|
|
|
|
public override float DamageMultiplier { get; }
|
|
|
|
public override float AttackSpeedMultiplier { get; }
|
|
|
|
[SerializeField]
|
|
private ResourceNodeType _resourceNodeType;
|
|
|
|
[SerializeField]
|
|
private float _gatherRate = 1f;
|
|
public float GatherRate => _gatherRate;
|
|
|
|
public override sealed void Start()
|
|
{
|
|
base.Start();
|
|
|
|
ChooseSkinForHarvester();
|
|
}
|
|
|
|
/// <summary>
|
|
/// changes the harvester's appearance depending on the resource they're harvesting
|
|
/// </summary>
|
|
private void ChooseSkinForHarvester()
|
|
{
|
|
//get the tile we're on
|
|
var tile = LevelManager.Instance.Get<ResourceTile>(t => t.Position == Position);
|
|
if (tile == default) return;
|
|
|
|
//if we already have the right harvester for the resource, no need to change
|
|
var resourceChoice = tile.ResourceNodeType;
|
|
if (resourceChoice == this.ResourceNodeType) return;
|
|
|
|
//get the right pair for the resource we're on
|
|
var harvResPair = _harvesterResourcePairs.Find(hrp => hrp.Resource == resourceChoice);
|
|
if (harvResPair == null) return;
|
|
|
|
//exchange harvesters
|
|
var newHarvester = Instantiate(harvResPair.HarvesterPrefab, transform.position, Quaternion.identity);
|
|
newHarvester.transform.SetParent(transform.parent);
|
|
Destroy(gameObject);
|
|
}
|
|
} |