public GameObject dropSheep() { if (sheepPickedup.Count == 0) { return(null); } GameObject droppedSheep = sheepPickedup.Pop(); SheepMovement droppedSheep_movement = droppedSheep.GetComponentInChildren <SheepMovement>(); Animator droppedSheep_animator = droppedSheep.GetComponentInChildren <Animator>(); Rigidbody droppedSheep_rb = droppedSheep.GetComponent <Rigidbody>(); // set state to available and anim state to iddle droppedSheep_movement.setAvailable(); IAnimState animState = new Iddle(ref droppedSheep_animator); droppedSheep_movement.SetAnimState(animState); sheepCollideWithBases(droppedSheep); changePlayerSpeed(); droppedSheep_rb.velocity = Vector3.zero; droppedSheep_rb.useGravity = true; SendDroppedSheepMessage(droppedSheep.transform.name, droppedSheep_movement.getState(), droppedSheep_animator.GetInteger("Index")); return(droppedSheep); }
public void processSheepMovementMessage(SheepMovementMessage _msg) { //server does not care about sheep movement receiving messages if (isServer) { return; } GameObject sheep = GameObject.Find(_msg.objectTransformName); if (sheep != null) { SheepMovement sheep_movement = sheep.GetComponent <SheepMovement>(); if (sheep_movement.getState() != (int)State.Unavailable) { sheep_movement.localMove(_msg.objectPosition, _msg.objectRotation, _msg.time, _msg.objectAnimation); } } }
private void shootSheep() { if (pickupSheep.getSheepStack().Count == 0) { impulseAccel = InitialImpulseAccel; impulseStrenthSpeed = InitialImpulseSpeed; impulseStrenth = InitialImpulseStrenght; updateImpulseUI(); return; } orientPlayer(); pickupSheep.updateSheepRotation(); hideMira(); GameObject sheep = pickupSheep.prepareToShoot(); SheepMovement sheep_movement = sheep.GetComponentInChildren <SheepMovement>(); Animator sheep_animator = sheep.GetComponentInChildren <Animator>(); Rigidbody sheep_rb = sheep.GetComponent <Rigidbody>(); // set state to flying and anim state to shot sheep_movement.setFlying(); IAnimState animState = new Shot(ref sheep_animator); sheep_movement.SetAnimState(animState); sheep_rb.velocity = Vector3.zero; sheep_rb.useGravity = true; // sheepCollideWithBases(sheep); sheepCollideWithPlayers(sheep); sheep_movement.setPickedUpBy(""); SendShootSheepMessage(sheep.transform.name, sheep_movement.getState(), sheep_animator.GetInteger("Index"), impulseStrenth); resetImpulseAndUI(); }