Skip to content
Snippets Groups Projects
Commit 1f65e1db authored by Erno Lokkila's avatar Erno Lokkila
Browse files

worker now looks where she goes

parent 83a2dac1
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@ GameObject:
m_Component:
- component: {fileID: 548039319383633026}
- component: {fileID: 548039319383633027}
- component: {fileID: 6298442855940817967}
- component: {fileID: 548039319383633029}
- component: {fileID: 548039319383633028}
- component: {fileID: 548039319383633031}
......@@ -82,6 +83,27 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!114 &6298442855940817967
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 548039319383633024}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 266b3ace213eb154d80f94023b63eabb, type: 3}
m_Name:
m_EditorClassIdentifier:
sprites:
- {fileID: 21300000, guid: 488af5ae9ee5f2e48b2879b969ebc0a1, type: 3}
- {fileID: 21300002, guid: 488af5ae9ee5f2e48b2879b969ebc0a1, type: 3}
- {fileID: 21300004, guid: 488af5ae9ee5f2e48b2879b969ebc0a1, type: 3}
- {fileID: 21300006, guid: 488af5ae9ee5f2e48b2879b969ebc0a1, type: 3}
- {fileID: 21300008, guid: 488af5ae9ee5f2e48b2879b969ebc0a1, type: 3}
- {fileID: 21300010, guid: 488af5ae9ee5f2e48b2879b969ebc0a1, type: 3}
- {fileID: 21300012, guid: 488af5ae9ee5f2e48b2879b969ebc0a1, type: 3}
- {fileID: 21300014, guid: 488af5ae9ee5f2e48b2879b969ebc0a1, type: 3}
--- !u!114 &548039319383633029
MonoBehaviour:
m_ObjectHideFlags: 0
......@@ -97,10 +119,15 @@ MonoBehaviour:
target: {fileID: 0}
move_to: {fileID: 0}
max_amount: 10
Requested_amount: 0
Requested_resource: {fileID: 0}
OnkoVapaa: 0
amount: 0
home: {fileID: 7607310651946833762, guid: 118ed7528555d45418acb5a87b330000, type: 3}
resource: {fileID: 0}
speed: 1
target_flag: {fileID: 0}
send_to_resource: 0
flag: {fileID: 8796312832300166883, guid: 5cba37404bc15114b929eea3f4ec84f3, type: 3}
--- !u!61 &548039319383633028
BoxCollider2D:
......
......@@ -44,6 +44,9 @@ public class Collector : MonoBehaviour
home = GameObject.FindGameObjectWithTag("Home");
}
public GameObject GetMoveToTarget() {
return move_to;
}
public void SetOnkoVapaa(bool vapaa)
{
this.OnkoVapaa = vapaa;
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CollectorMover : MonoBehaviour
{
[SerializeField]
Sprite[] sprites = null;
Collector col;
// Start is called before the first frame update
void Start()
{
col = gameObject.GetComponent<Collector>();
}
// Update is called once per frame
void Update()
{
//Vector3 target = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector3 target = col.GetMoveToTarget().transform.position;
Vector3 dir = target - transform.position;
GameObject go = new GameObject();
go.transform.position = target;
dir = go.transform.InverseTransformDirection(dir);
float angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
angle += 22.5f;
Debug.Log(angle);
Destroy(go);
SpriteRenderer rd = gameObject.GetComponent<SpriteRenderer>();
if(angle > -180 && angle < -135f)
{
rd.sprite = sprites[3];
}
else if (angle > -135f && angle < -90f)
{
rd.sprite = sprites[1];
}
else if (angle > -90f && angle < -45f)
{
rd.sprite = sprites[0];
}
else if (angle > -45f && angle < 0f)
{
rd.sprite = sprites[2];
}
else if (angle > 0f && angle < 45f)
{
rd.sprite = sprites[4];
}
else if (angle > 45f && angle < 90f)
{
rd.sprite = sprites[6];
}
else if (angle > 90f && angle < 135f) {
rd.sprite = sprites[7];
}
else if (angle > 135f && angle < 180f)
{
rd.sprite = sprites[5];
}
else
{
rd.sprite = sprites[3];
}
}
}
fileFormatVersion: 2
guid: 266b3ace213eb154d80f94023b63eabb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 23dbd6b7f8b166f408cdb676d37102ad
TextureImporter:
fileIDToRecycleName: {}
externalObjects: {}
serializedVersion: 9
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: e6e209070f1e3b140b0aabd1e522e3fe
vertices: []
indices:
edges: []
weights: []
spritePackingTag:
pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment