private float tamanhoBarra; //armazena o tamanho original da barra de vida // Use this for initialization void Start() { Mosquito mosquito = GetComponentInParent <Mosquito> (); tamanhoBarra = gameObject.transform.localScale.x; //o tamanho original da vida vai ser igual a scale local do objeto definido no editor vidaMaxima = mosquito.vida; }
void Start() { for (int i = 0; i < 1; i++) { SpawnChild(_swarmParent.position); } _swarmMaster = _swarm[0]; }
public void SetFeeding(Mosquito mosq, bool feeding) { if (feeding) { mosq._t.parent = _swarmParentFeeding; } else { mosq._t.parent = _swarmParent; } }
void Update() { float intervaloTempo = Time.time - tempoInicio; //instavelo de tempo para a proxima bala sair gameObject.transform.position = //a posição da bala vai ser alterada de acordo com a Vector3.Lerp(posicaoInicial, posicaoAlvo, //interpolação linear entre dois pontosl evando em consideração o tempo, intervaloTempo * velocidade / distancia); //que neste caso traduz o intervalo que a bala sai, vezes a velocidade dividido pela distancia if (gameObject.transform.position.Equals(posicaoAlvo)) //se a posição da bala for igual a posição do inimigo { if (alvo != null) //se o alvo não for nulo { Mosquito inimigo = alvo.GetComponent <Mosquito> (); //Cria-se um objeto do tipo mosquito recebendo o compoente Mosquito presente no gameObject alvo inimigo.RecebeuDano(dano); //esse objeto executa o metodo recebeuDano Instantiate(efeito, gameObject.transform.position, Quaternion.identity); //instancia o efeito de explosão } Destroy(gameObject); //por fim detroi a bala } }
static void Main(string[] args) { //Animal.Animal beast = new Animal.Animal(); //beast.Talk(); //beast.Greet(); //beast.Sing(); Dog bowser = new Dog(); bowser.Talk(); bowser.Greet(); bowser.Sing(); bowser.Fetch("stick"); bowser.FeedMe(); bowser.TouchMe(); Robin red = new Robin(); red.Talk(); red.Greet(); red.Sing(); //red.Fetch("worm"); //red.FeedMe(); //red.TouchMe(); Mosquito buzzy = new Mosquito(); buzzy.Fly(); Horse gerald = new Horse(); gerald.Ride(); Griffon flamel = new Griffon(); flamel.Fly(); flamel.Ride(); Console.ReadKey(); }
public void StartSimulation() { /* * Function that initialises and begins the simulation. * Processes: * 1) Clears all entities currently in operation. * 2) Sets the parameters of the simulation according to the parameteres * chosen by the user. * 3) Initialises the SIR equation parameters * 4) Camera is initialised using a calculated spawnRadius parameter based * on the number of mosquitos and humans and the density parameter. * 5) Loops through hNum to create each human and place them in the 2D world space. * 6) Loops through mNum to create each mosquito and place them in the 2D world space. * 7) The simulation is set to active. */ //1 ClearEntities(); //2 hNum = (int)Preset.current.humanData ["Population Size"]; float hInfectedStart = Preset.current.humanData ["Percentage Infected"]; hRecoveryRate = Preset.current.humanData ["Percentage Recovery"]; hTransferChance = Preset.current.humanData ["Transfer Chance"]; hDensity = Preset.current.humanData ["Density"]; mNum = (int)Preset.current.mosquitoData ["Population Size"]; float mInfectedStart = Preset.current.mosquitoData ["Percentage Infected"]; mRecoveryRate = Preset.current.mosquitoData ["Percentage Recovery"]; mTransferChance = Preset.current.mosquitoData ["Transfer Chance"]; mBiteRate = Preset.current.mosquitoData ["Bite Rate"]; //3 SIR_hInfected = hInfectedStart; SIR_mInfected = mInfectedStart; //4 float spawnRadius = humanPrefab.transform.localScale.x * 4 * Mathf.Sqrt(hNum + mNum) / hDensity; UI.InitialiseCamera(50, (int)spawnRadius * 2, (int)spawnRadius); //5 for (int i = 0; i < hNum; i++) { bool infected = (float)(i + 1) / hNum <= hInfectedStart ? true : false; GameObject temp = (GameObject)Instantiate(humanPrefab); Vector2 circle = Random.insideUnitCircle * spawnRadius; temp.transform.localPosition = new Vector3(circle.x, circle.y, 0); Human human = new Human(temp.transform, infected, hRecoveryRate, hTransferChance, hMoveSpeed); humans.Add(human); } //6 for (int i = 0; i < mNum; i++) { bool infected = (float)(i + 1) / mNum <= mInfectedStart ? true : false; GameObject temp = (GameObject)Instantiate(mosquitoPrefab); Vector2 circle = Random.insideUnitCircle * spawnRadius; temp.transform.localPosition = new Vector3(circle.x, circle.y, 0); Mosquito mosquito = new Mosquito(temp.transform, infected, mRecoveryRate, mTransferChance, mMoveSpeed, mBiteRate); mosquitos.Add(mosquito); } //7 SetActivity(true); }
private static List<Mosquito> ScatterMosquitos(Game game, int numMosquitos, float minDistance, int distance, Player player) { List<Mosquito> mosquitoList = new List<Mosquito>(); for (int i = 0; i < numMosquitos; i++) { Mosquito mosquito = new Mosquito(game, UnitTypes.MosquitoType.Mosquito); mosquito.Initialize(); // Generate a random position Vector3 offset = RandomHelper.GeneratePositionXZ(distance); while (Math.Abs(offset.X) < minDistance && Math.Abs(offset.Z) < minDistance) offset = RandomHelper.GeneratePositionXZ(distance); mosquito.Transformation = new Transformation(player.Transformation.Translate + offset, Vector3.Zero, /*Vector3.One*/ new Vector3((float)1, (float)1, (float)1)); mosquito.TransformationOld = mosquito.Transformation; mosquitoList.Add(mosquito); } return mosquitoList; }