override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateEnter(animator, stateInfo, layerIndex); gather = unit.gather; movement = unit.movement; TimeTickSystem.OnTick += TimeTickSystem_OnTick; }
private void Awake() { characterAnimator = GetComponent <CharacterAnimator>(); unit = GetComponent <Unit>(); sense = GetComponent <SenseController>(); movement = GetComponent <MovementController>(); gather = GetComponent <GatherController>(); animator = GetComponent <Animator>(); }
protected override void Awake() { base.Awake(); worldObjectType = ObjectType.Character; gather = GetComponent <GatherController>(); if (player != null) { player.characters.Add(this); } animator = GetComponent <Animator>(); animator.SetBool("HasArrived", true); }
void Start() { //Initialise variables properties = transform.GetComponent <UnitProperties> (); speed = properties.speed; destination = transform.position; hasDestination = false; stoppedCurrentAction = false; attackTargetGiven = false; gatherer = transform.GetComponent <GatherController> (); fighter = transform.GetComponent <FighterController> (); }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { base.OnStateEnter(animator, stateInfo, layerIndex); TimeTickSystem.OnTick += TimeTickSystem_OnTick; gather = unit.gather; resource = aIController.actualTarget.GetComponent <Resource>(); if (resource) { Vector2 direction = BigBookBasic.GetDirectionVector2(resource.transform.position, unitObject.transform.position); characterAnimator.GetAnimationFromVector2(direction.x, direction.y, resource.gatherAnimation); } else { animator.SetBool("HasArrived", true); animator.SetBool("IsGathering", false); } }
public void ExtractResource(float amount, GatherController gather) { if (resourceAmount <= 0) { DestroyResource(gather); } if (resourceAmount < amount) { amount = resourceAmount; } if (gather.hasResourceType == resourceType) { if (gather.hasResourceAmount + amount > gather.maxResourceAmount) { amount = gather.maxResourceAmount - gather.hasResourceAmount; } if (amount != 0) { resourceAmount -= amount; gather.hasResourceAmount += amount; if (resourceAmount <= .1f) { gather.hasResourceAmount += resourceAmount; resourceAmount -= resourceAmount; } } else { //valt niet te extracten. } } else { if (gather.canExtractResourceType.Contains(resourceType)) { gather.hasResourceAmount = 0; gather.hasResourceType = resourceType; } } }
private MovementController[] SkipImpossible(WorldObject worldObject, MovementController[] units) { List <MovementController> possibleUnits = new List <MovementController>(); units = OnlyOwnObjects <MovementController>(units).ToArray(); switch (worldObject.worldObjectType) { case ObjectType.Building: return(units); case ObjectType.Character: return(units); case ObjectType.Resource: { //alleen units die uberhaupt resources kunnen dragen kunnen interactie met resources hebben. for (int u = 0; u < units.Length; u++) { WorldObject unitWo = units[u].GetComponent <WorldObject>(); if (unitWo != null) { if (unitWo.player == player) { GatherController gather = units[u].GetComponent <GatherController>(); if (gather != null) { if (gather.maxResourceAmount > 0) { possibleUnits.Add(units[u]); } } } } } break; } } return(possibleUnits.ToArray()); }
private void DestroyResource(GatherController gatherController) { //Grid bijwerken, want obstakel valt weg //destroy object //eventueel character nieuwe instructie geven }