public void SpawnState(Vector3Int spawnState) { // Missionaries Spawnning for (int i = 1; i <= spawnState.x; i++) { GameObject newMissionary = Instantiate(missionary, transform.position, Quaternion.identity); newMissionary.GetComponent <SpriteRenderer>().sortingOrder = i + spawnState.x; newMissionary.GetComponent <Animator>().speed = 1f + UnityEngine.Random.Range(-maxAnimationVariance, maxAnimationVariance); newMissionary.GetComponent <Interactable>().dropzone = boat; initialDropzone.AddItem(newMissionary); } // Cannibal Spawnning for (int i = 1; i <= spawnState.y; i++) { GameObject newCannibal = Instantiate(cannibal, transform.position, Quaternion.identity); newCannibal.GetComponent <SpriteRenderer>().sortingOrder = spawnState.y - i + 1; newCannibal.GetComponent <Animator>().speed = 1f + UnityEngine.Random.Range(-maxAnimationVariance, maxAnimationVariance); newCannibal.GetComponent <Interactable>().dropzone = boat; initialDropzone.AddItem(newCannibal); } }
private void OnMouseDown() { Dropzone previousDropzone = transform.parent.GetComponent <Dropzone>(); if (canInteract && dropzone != null) { dropzone.AddItem(gameObject); dropzone = previousDropzone; } }
private void BoatBankToggleHandler() { Vector3Int boatState = new Vector3Int(0, 0, 1); Dropzone nextDropzone = (boat.onLeftBank) ? leftBank : rightBank; int childCount = boat.transform.childCount; List <Interactable> children = new List <Interactable>(); for (int i = 0; i < childCount; i++) { Interactable interactable = boat.transform.GetChild(i).GetComponent <Interactable>(); if (interactable.interactableType == Interactable.InteractableType.Missionary) { boatState += new Vector3Int(1, 0, 0); } else if (interactable.interactableType == Interactable.InteractableType.Cannibal) { boatState += new Vector3Int(0, 1, 0); } children.Add(interactable); } for (int i = 0; i < children.Count; i++) { nextDropzone.AddItem(children[i].gameObject); children[i].dropzone = boat.GetComponent <Dropzone>(); } if (boat.onLeftBank) { currentState = currentState.AddState(boatState); } else { currentState = currentState.SubtractState(boatState); } bool isValid = currentState.IsValid(initalState); Debug.Log("Current State: " + currentState.ToString() + " isValid: " + isValid.ToString()); if (!isValid) { Dropzone killzone = (currentState.x < currentState.y) ? leftBank : rightBank; KillMissonaries(killzone); ShowGameOver(isValid); } else if (currentState == goalState) { ShowGameOver(isValid); } }