Commit 4c927f75 authored by You're Perfect 's avatar You're Perfect

AI improvements, player2 button works

parent e6e7a245
......@@ -4,7 +4,6 @@ using UnityEngine;
public class Bear : MonoBehaviour {
public IEnumerator PlayScoreAnimation(int points)
{
Animator anim = GetComponent<Animator>();
......
......@@ -7,6 +7,7 @@ public class FishFactory : MonoBehaviour {
public int MinimumFishCount;
public GameObject []fishPrefabs;
public GameObject []veryRareFish;
public LayerMask FishLayer;
public float veryRareFishProbability = 0.001f;
public float delay=60.0f*60.0f;
......@@ -23,10 +24,13 @@ public class FishFactory : MonoBehaviour {
//Transform newTransform = transform;
//newTransform.position=transform.position = new Vector3 (transform.position.x, transform.position.y +Random.Range(0,rangeVal), transform.position.z);
GameObject newFish;
if (Random.value < Instance.veryRareFishProbability && Instance.veryRareFish.Length > 0)
Instantiate(Instance.veryRareFish[Random.Range(0, (Instance.veryRareFish.Length) - 1)], newVect, Quaternion.identity, Instance.transform);
newFish = Instantiate(Instance.veryRareFish[Random.Range(0, (Instance.veryRareFish.Length) - 1)], newVect, Quaternion.identity, Instance.transform);
else
Instantiate(Instance.fishPrefabs[Random.Range(0, (Instance.fishPrefabs.Length) - 1)], newVect, Quaternion.identity, Instance.transform);
newFish = Instantiate(Instance.fishPrefabs[Random.Range(0, (Instance.fishPrefabs.Length) - 1)], newVect, Quaternion.identity, Instance.transform);
newFish.layer = Instance.FishLayer.value;
}
}
......
......@@ -45,16 +45,17 @@ public class Mouth : MonoBehaviour {
pos = GameObject.Find (hookstr);
pos.GetComponent<BoxCollider2D> ().enabled = false;
}
else
{
else {
SwingController lc = rodObj.GetComponent<SwingController>();
lc.hooked = true;
lc.hookedFish = transform.gameObject;
string hookstr = "hook" + player;
Debug.Log (hookstr);
pos = GameObject.Find (hookstr);
pos.GetComponent<BoxCollider2D> ().enabled = false;
}
string hookstr = "hook" + player;
Debug.Log (hookstr);
pos = GameObject.Find (hookstr);
pos.GetComponent<BoxCollider2D> ().enabled = false;
AIbear ai = GameObject.Find("AI").GetComponent<AIbear>();
ai.hooked = true;
}
hooked = true;
}
......@@ -74,6 +75,7 @@ public class Mouth : MonoBehaviour {
if (GameObject.Find ("AI") != null) {
AIbear ai = GameObject.Find ("AI").GetComponent<AIbear> ();
ai.target = null;
ai.hooked = false;
}
}
pos.GetComponent<BoxCollider2D>().enabled=true;
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class whale1 : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
fileFormatVersion: 2
guid: afcda15d4e5a8de4db3c835087ea4b8f
timeCreated: 1533832679
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -9,11 +9,16 @@ public class AIbear : MonoBehaviour {
public LayerMask fishlayer;
LineController vert;
RodController horiz;
public bool hooked = false;
void SearchFish(Vector2 center,Vector2 boxsize, float angle)
{
Collider2D hit = Physics2D.OverlapBox(center,boxsize,angle,fishlayer);
if (hit == null || hit.gameObject == null)
{
Debug.Log("NoFish");
target = null;
}
else
target = hit.gameObject;
//target =targets [Random.Range (0, targets.Length - 1)].gameObject ;
......@@ -25,35 +30,62 @@ public class AIbear : MonoBehaviour {
GameObject o2 = GameObject.Find ("RodPoint2");
horiz = o2.GetComponent<RodController>();
}
public float targetTimeout = 5;
void FixedUpdate () {
if (target != null) {
if (!SoundManager.Player2AI)
return;
if (target.transform.position.x > transform.position.x) {
horiz.value = 1;
}
else
if (target.transform.position.x < transform.position.x) {
horiz.value = -1;
} else
horiz.value = 0;
if (!hooked)
{
if (target.transform.position.y > transform.position.y) {
vert.value = 1;
}
else
if (target.transform.position.y < transform.position.y) {
if (target != null)
{
if (target.transform.position.x > transform.position.x + 2)
{
horiz.value = 1;
}
else if (target.transform.position.x < transform.position.x - 2)
{
horiz.value = -1;
}
else
{
horiz.value = 0;
}
if (target.transform.position.y > transform.position.y)
{
vert.value = 1;
}
else if (target.transform.position.y < transform.position.y)
{
vert.value = -1;
} else
}
else
{
vert.value = 0;
}
targetTimeout -= Time.deltaTime;
if (targetTimeout < 0)
{
targetTimeout = 5;
target = null;
}
} else {
SearchFish (new Vector2(transform.position.x,transform.position.y), size,angle);
}
else
{
targetTimeout = 5;
SearchFish(new Vector2(transform.position.x, transform.position.y), size, angle);
}
}
else
{
vert.value = 1;
}
}
......
fileFormatVersion: 2
guid: 4c6005af2aa8e6c4a9d7cc9090300185
timeCreated: 1534134348
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
......
......@@ -10,9 +10,12 @@ public class SoundManager : MonoBehaviour {
public AudioClip WhaleSound;
public AudioClip SplashSound;
//These need to be moved to some other class
public Animator LeftBear;
public Animator RightBear;
public MainMenu MainMenu;
internal static bool Player2AI = true;
internal static SoundManager Instance;
......@@ -41,12 +44,19 @@ public class SoundManager : MonoBehaviour {
/// </summary>
public void Update()
{
if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Q)) {
if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Q))
{
if (MainMenu.gameObject != null && MainMenu.gameObject.activeInHierarchy) {
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false;
UnityEditor.EditorApplication.isPlaying = false;
#else
Application.Quit ();
#endif
}
else
{
MainMenu.gameObject.SetActive(true);
}
}
}
......
fileFormatVersion: 2
guid: 3c87f4ee434fd2846a87145440bc317b
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 0
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 23
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
- serializedVersion: 2
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 7ec6565359925f340ab54ab9e395146d
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
......@@ -13,6 +13,12 @@ public class MainMenu : MonoBehaviour {
public GameObject KeyboardControlsInfo;
public Text Player1Winner;
public Text Player2Winner;
public Sprite RobotIcon;
public Sprite HumanIcon;
public Sprite NoneIcon;
public Button Player2Button;
public LineController Player2Line;
public RodController Player2Rod;
void OnEnable () {
//KeyboardControlsInfo.SetActive(false);
......@@ -58,4 +64,22 @@ public class MainMenu : MonoBehaviour {
StartCoroutine(PlayGameMusicAndClose());
StartCoroutine(HideKeyboardControls());
}
public void OnPlayer2Clicked()
{
SoundManager.Player2AI = !SoundManager.Player2AI;
if(SoundManager.Player2AI)
{
Player2Button.image.sprite = RobotIcon;
Player2Line.HumanControlled = false;
Player2Rod.HumanControlled = false;
}
else
{
Player2Button.image.sprite = HumanIcon;
Player2Line.HumanControlled = true;
Player2Rod.HumanControlled = true;
}
}
}
fileFormatVersion: 2
guid: 63fec4a281d2d9644bbcc9615f901bf6
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 7
mipmaps:
mipMapMode: 0
enableMipMap: 0
sRGBTexture: 1
linearTexture: 0
fadeOut: 0
borderMipMap: 0
mipMapsPreserveCoverage: 0
alphaTestReferenceValue: 0.5
mipMapFadeDistanceStart: 1
mipMapFadeDistanceEnd: 3
bumpmap:
convertToNormalMap: 0
externalNormalMap: 0
heightScale: 0.25
normalMapFilter: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 0
seamlessCubemap: 0
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: -1
aniso: -1
mipBias: -100
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 0
lightmap: 0
compressionQuality: 50
spriteMode: 1
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 1
spriteTessellationDetail: -1
textureType: 8
textureShape: 1
singleChannelComponent: 0
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
platformSettings:
- serializedVersion: 2
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []
outline: []
physicsShape: []
bones: []
spriteID: 41150f9f0ddfeec4da4d67fecc83df86
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment