create mob attack

This commit is contained in:
dart 2022-04-02 20:42:29 +03:00
parent fa6411f936
commit 1d13cb09df
8 changed files with 112 additions and 4 deletions

1
.gitignore vendored
View File

@ -82,3 +82,4 @@ Temp
obj obj
Logs Logs
/.gitignore~ /.gitignore~
/ldjam50/Logs/ApiUpdaterCheck.txt

View File

@ -125,7 +125,7 @@ BoxCollider2D:
m_Enabled: 1 m_Enabled: 1
m_Density: 1 m_Density: 1
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_IsTrigger: 0 m_IsTrigger: 1
m_UsedByEffector: 0 m_UsedByEffector: 0
m_UsedByComposite: 0 m_UsedByComposite: 0
m_Offset: {x: -0.020021677, y: 0.0039904118} m_Offset: {x: -0.020021677, y: 0.0039904118}

View File

@ -43,7 +43,7 @@ BoxCollider2D:
m_Enabled: 1 m_Enabled: 1
m_Density: 1 m_Density: 1
m_Material: {fileID: 0} m_Material: {fileID: 0}
m_IsTrigger: 0 m_IsTrigger: 1
m_UsedByEffector: 0 m_UsedByEffector: 0
m_UsedByComposite: 0 m_UsedByComposite: 0
m_Offset: {x: -0.0049001575, y: -0.026252389} m_Offset: {x: -0.0049001575, y: -0.026252389}
@ -71,6 +71,10 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 7dc89d6f20b8bd496a76c3dad9b1b832, type: 3} m_Script: {fileID: 11500000, guid: 7dc89d6f20b8bd496a76c3dad9b1b832, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
characterObject: {fileID: 0}
moveSpeed: 0
minDist: 0
maxDist: 0
--- !u!1 &6540482753690656168 --- !u!1 &6540482753690656168
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0

View File

@ -47,4 +47,9 @@ public StatReturn GetStats()
}; };
return stats; return stats;
} }
public void ApplyDamage(float newDamage)
{
damage += newDamage;
}
} }

View File

@ -1,3 +1,4 @@
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -27,7 +28,34 @@ void Update()
{ {
//transform.position += transform.forward * moveSpeed * Time.deltaTime; //transform.position += transform.forward * moveSpeed * Time.deltaTime;
transform.position += (characterObject.transform.position-transform.position) * moveSpeed * Time.deltaTime;
var rawCharacterVector = characterObject.transform.position - transform.position;
var characterVector = new Vector3(
Mathf.Clamp(rawCharacterVector.x, -moveSpeed, moveSpeed),
Mathf.Clamp(rawCharacterVector.y, -moveSpeed, moveSpeed),
0);
if (characterVector.x < 1f && characterVector.x > 0)
{
characterVector.x = 1f;
}
if (characterVector.y < 1f && characterVector.y > 0)
{
characterVector.y = 1f;
}
if (characterVector.x > 1f && characterVector.x < 0)
{
characterVector.x = 1f;
}
if (characterVector.y > -1f && characterVector.y < 0)
{
characterVector.y = 1f;
}
//print(characterVector);
transform.position += (characterObject.transform.position-transform.position) * (moveSpeed * Time.deltaTime);
@ -38,4 +66,16 @@ void Update()
} }
} }
} }
private void OnTriggerEnter2D(Collider2D col)
{
print("Detect");
gameObject.SetActive(false);
}
public void SetupMob(OverMind.MobParameters mobParameters)
{
characterObject = mobParameters.Character;
moveSpeed = mobParameters.MoveSpeed;
}
} }

View File

@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class OverMind : MonoBehaviour
{
[SerializeField] private GameObject mob;
[SerializeField] private GameObject megaMob;
[SerializeField] private int pullSize;
[SerializeField] private GameObject characterObject;
[SerializeField] private float mobMoveSpeed;
private List<GameObject> _pullEnemies;
public struct MobParameters
{
public float MoveSpeed;
public GameObject Character;
}
void Start()
{
PreHeaterSpawn();
}
private void PreHeaterSpawn()
{
for (var i = 0; i < pullSize; i++)
{
var newMob = Instantiate(mob,transform);
var newMobParameters = new MobParameters
{
MoveSpeed = mobMoveSpeed,
Character = characterObject
};
newMob.GetComponent<Mob>().SetupMob(newMobParameters);
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a35c03cf584d904acac0d316af6a31fb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -3,7 +3,8 @@
--- !u!78 &1 --- !u!78 &1
TagManager: TagManager:
serializedVersion: 2 serializedVersion: 2
tags: [] tags:
- Character
layers: layers:
- Default - Default
- TransparentFX - TransparentFX