This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

Binary file not shown.

This file was deleted.

BIN -2.32 KB Assets/Point 1.png
Deleted file not rendered

This file was deleted.

@@ -44,8 +44,8 @@ Rigidbody2D:
m_LinearDrag: 0
m_AngularDrag: 0
m_GravityScale: 0
m_IsKinematic: 1
m_Interpolate: 0
m_IsKinematic: 0
m_Interpolate: 1
m_SleepingMode: 1
m_CollisionDetection: 0
m_Constraints: 0
@@ -60,7 +60,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: db597088f6f24b2479f0505ed49e0dce, type: 3}
m_Name:
m_EditorClassIdentifier:
timeStep: 0.008
timeStep: 0.01
_stepNumber: 0
--- !u!114 &11459888
MonoBehaviour:
@@ -84,7 +84,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2420bf6d6af72a54b8ac8af517cb2785, type: 3}
m_Name:
m_EditorClassIdentifier:
density: 20000
Density: 0.05
dotPrefab1: {fileID: 157696, guid: 9e901f9de365da944bea1292c3a8474c, type: 2}
dotPrefab2: {fileID: 157696, guid: 9e901f9de365da944bea1292c3a8474c, type: 2}
firstDot: 0
@@ -163,7 +163,7 @@ Prefab:
objectReference: {fileID: 157696, guid: 9e901f9de365da944bea1292c3a8474c, type: 2}
- target: {fileID: 0}
propertyPath: m_Interpolate
value: 0
value: 1
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: m_LinearDrag
@@ -191,11 +191,15 @@ Prefab:
objectReference: {fileID: 157696, guid: 9e901f9de365da944bea1292c3a8474c, type: 2}
- target: {fileID: 0}
propertyPath: m_IsKinematic
value: 1
value: 0
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: timeStep
value: 0.008
value: 0.01
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: Density
value: 0.05
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -103,7 +103,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 2420bf6d6af72a54b8ac8af517cb2785, type: 3}
m_Name:
m_EditorClassIdentifier:
density: 1
Density: 10
dotPrefab1: {fileID: 124726, guid: 9e3741433f5d6054dae0a5551f1ab35d, type: 2}
dotPrefab2: {fileID: 0}
firstDot: 0
@@ -321,6 +321,10 @@ Prefab:
propertyPath: timeStep
value: 0.01
objectReference: {fileID: 0}
- target: {fileID: 0}
propertyPath: Density
value: 10
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 110198}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -359,8 +359,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: beae6668dd88a21499b7d09ad9762512, type: 3}
m_Name:
m_EditorClassIdentifier:
startRadius: 10
shotForceMax: 50
StartRadius: 0
ShotForceMax: 100
--- !u!1001 &952744977
Prefab:
m_ObjectHideFlags: 0
@@ -948,7 +948,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 5036870, guid: 65a8796b54c8f764191fcd9e2fd9664c, type: 2}
propertyPath: m_Mass
value: 500
value: 50000
objectReference: {fileID: 0}
- target: {fileID: 5036870, guid: 65a8796b54c8f764191fcd9e2fd9664c, type: 2}
propertyPath: m_AngularDrag
@@ -960,7 +960,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 5036870, guid: 65a8796b54c8f764191fcd9e2fd9664c, type: 2}
propertyPath: m_IsKinematic
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 65a8796b54c8f764191fcd9e2fd9664c, type: 2}
File renamed without changes.
@@ -3,62 +3,59 @@
using System;


class Attractable : MonoBehaviour, IVisitor {
class Attractable : MonoBehaviour, IVisitor {

ConstantForce2D constForce;
Rigidbody2D rb2d;
Movable movement;

Element[] elements;

Vector2 gravityField;

public void visitElement(Attractor attractor) {
public void visitElement(Attractor attractor)
{
gravityField += calculateForce(attractor.getMass(), attractor.getPosition()); // Прибавить силу действующую со стороны Attractor
}
public void visitElement(Repulser repulser) {

gravityField -= calculateForce(repulser.getMass(), repulser.getPosition()); // Вычесть силу действующую со стороны Repulser

public void visitElement(Repulser repulser)
{
gravityField -= calculateForce(repulser.getMass(), repulser.getPosition()); // Вычесть силу действующую со стороны Repulser
}

void Awake()
{

constForce = GetComponent<ConstantForce2D>();
rb2d = GetComponent<Rigidbody2D>();
movement = GetComponent<Movable>();
elements = FindObjectsOfType(typeof(Element)) as Element[];

}


public Vector2 calculateForce(float attractorMass, Vector2 attractorPosition) {
public Vector2 calculateForce(float attractorMass, Vector2 attractorPosition)
{
float angle;
float dist = Vector2.Distance(attractorPosition, this.transform.position);
Vector2 forceVect = attractorPosition - (Vector2)transform.position;
if (attractorPosition.x < transform.position.x){ // Так как угол определяемый Vector2.Angle() у меня получался от 0 до 180
if (attractorPosition.x < transform.position.x)
{ // Так как угол определяемый Vector2.Angle() у меня получался от 0 до 180
angle = (360 - (Vector2.Angle(forceVect, Vector2.up)))*Mathf.PI/180.0f;
}
else {
else
{
angle = (Vector2.Angle(forceVect, Vector2.up)) * Mathf.PI / 180.0f;
}
float gravityFieldValue =(attractorMass)/(dist*dist);

return new Vector2((gravityFieldValue * Mathf.Sin(angle)), (gravityFieldValue * Mathf.Cos(angle)));


}

public Vector2 getGravityField() {

public Vector2 getGravityField()
{
gravityField = Vector2.zero;
foreach (Element el in elements) //я не очень представляю, как правильно сложить силы, если это дело реализовать как положено в element, то каждый объект element будет по отдельности по очереди тянуть)
{
el.accept(this);

}
return gravityField;


}
}
@@ -7,4 +7,5 @@ public class Controller{
public static Message<float> Fire = new Message<float>();
public static Message<float> demoFire = new Message<float>();
public static Message<float> fillRadialElement = new Message<float>();
public static Message demoMissileDestroy = new Message();
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,8 +1,8 @@
using UnityEngine;
using System.Collections;

interface IVisitor {
void visitElement(Attractor attractor);
void visitElement(Repulser repulser);

}
using UnityEngine;
using System.Collections;

interface IVisitor {
void visitElement(Attractor attractor);
void visitElement(Repulser repulser);

}
File renamed without changes.
@@ -1,38 +1,38 @@
using UnityEngine;
using System.Collections;

public class InvisibleObjectsDestroyer : MonoBehaviour {
//private Renderer _renderer;
StateChanger _stateChanger;
public TrailMaker trailMaker;
// Use this for initialization
void Start () {
//_renderer = GetComponent<Renderer> ();
_stateChanger = GetComponent<StateChanger>();
}

// Update is called once per frame
void OnBecameInvisible()
{
if (TouchHandler.applicationIsRunning)
{
if (this.enabled) // Otherwise this function is called when object is destroyed
{

Debug.Log("FuckME");

Destroy(this.gameObject);
_stateChanger.ChangeState();
}
}
}
void Update () {
//if (!_renderer.isVisible) {
// Destroy(this.gameObject);
// _stateChanger.ChangeState();
//
//}

}

}
using UnityEngine;
using System.Collections;

public class InvisibleObjectsDestroyer : MonoBehaviour {

private StateChanger _stateChanger;
public TrailMaker trailMaker;

void Start ()
{
_stateChanger = GetComponent<StateChanger>();
}

// Update is called once per frame
void OnBecameInvisible()
{
if (TouchHandler.applicationIsRunning)
{
if (this.enabled) // Otherwise this function is called when object is destroyed
{

Debug.Log("FuckME");

Destroy(this.gameObject);
_stateChanger.ChangeState();
}
}
}
void Update () {
//if (!_renderer.isVisible) {
// Destroy(this.gameObject);
// _stateChanger.ChangeState();
//
//}

}

}
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,48 +1,40 @@
using UnityEngine;
using UnityEngine.Events;
using System;
using System.Reflection;


public class StateChangeListener : MonoBehaviour {

public UnityEvent onEnableState;
public UnityEvent onDisableState;
[HideInInspector]
public string stateMachineName;
[HideInInspector]
public int stateMachineIndex;
[HideInInspector]
public string enumName;
[HideInInspector]
public string stateName;
[HideInInspector]
public int stateIndex;



// Use this for initialization
void Awake(){
StateMachine<GameStates>.OnStateChange.Subscribe (OnStateChange);

}

void OnStateChange(GameStates PreviousState, GameStates NextState){
if (NextState.ToString() == stateName) {
//Debug.Log("StateChanged");
Debug.Log(NextState);
onEnableState.Invoke();

}
if (PreviousState.ToString() == stateName)
{
onDisableState.Invoke();
}

}





}
using UnityEngine;
using UnityEngine.Events;
using System;
using System.Reflection;


public class StateChangeListener : MonoBehaviour {

public UnityEvent onEnableState;
public UnityEvent onDisableState;
[HideInInspector]
public string stateMachineName;
[HideInInspector]
public int stateMachineIndex;
[HideInInspector]
public string enumName;
[HideInInspector]
public string stateName;
[HideInInspector]
public int stateIndex;


// Use this for initialization
void Awake()
{
StateMachine<GameStates>.OnStateChange.Subscribe (OnStateChange);
}

void OnStateChange(GameStates PreviousState, GameStates NextState)
{
if (NextState.ToString() == stateName)
{
onEnableState.Invoke();
}
if (PreviousState.ToString() == stateName)
{
onDisableState.Invoke();
}
}
}
File renamed without changes.
@@ -1,39 +1,39 @@
using UnityEngine;

using System;
using System.Reflection;


public class StateChanger: MonoBehaviour {



public string stateMachineName;
public int stateMachineIndex;

public string enumName;

public string stateName;
public int stateIndex;

private PropertyInfo _curState;
private object _stateMachine;
private object _state;

public void ChangeState()
{
_curState.SetValue(_stateMachine, _state, null);
}
public void Awake() //To call next code only once
{
string _stateMachineClassName = "StateMachine." + stateMachineName;
Type _stateMachineClass = typeof(StateChanger).Assembly.GetType(_stateMachineClassName);
FieldInfo[] _stateMachineClassFields = _stateMachineClass.GetFields();
_stateMachine = _stateMachineClassFields[0].GetValue(null);
Type _stateMachineBasicClass = typeof(StateChanger).Assembly.GetType(_stateMachine.GetType().FullName.ToString());
_curState = _stateMachineBasicClass.GetProperty("curState");
Type _enumType = typeof(StateChanger).Assembly.GetType(enumName);
_state = Enum.ToObject(_enumType, stateIndex);

}
}
using UnityEngine;
using System;
using System.Reflection;


public class StateChanger: MonoBehaviour {

public string stateMachineName;
public int stateMachineIndex;

public string enumName;

public string stateName;
public int stateIndex;

private PropertyInfo _curState;
private object _stateMachine;
private object _state;

public void ChangeState()
{
_curState.SetValue(_stateMachine, _state, null);
}
/// <summary>
///
/// </summary>
public void Awake()
// To call next code only once.
{
string _stateMachineClassName = "StateMachine." + stateMachineName;
var _stateMachineClass = typeof(StateChanger).Assembly.GetType(_stateMachineClassName);
FieldInfo[] _stateMachineClassFields = _stateMachineClass.GetFields();
_stateMachine = _stateMachineClassFields[0].GetValue(null);
var _stateMachineBasicClass = typeof(StateChanger).Assembly.GetType(_stateMachine.GetType().FullName.ToString());
var _enumType = typeof(StateChanger).Assembly.GetType(enumName);
_state = Enum.ToObject(_enumType, stateIndex);

}
}
File renamed without changes.
@@ -1,35 +1,36 @@
using UnityEngine;
using System.Collections;
using System.Reflection;
using System;
using System;

public class StateMachine<T> where T : struct, IComparable, IConvertible, IFormattable
{
public static Message<T, T> OnStateChange = new Message<T, T>();

private T _curState;
public StateMachine(T defaultState){

public StateMachine(T defaultState)
{
_curState = defaultState;
Debug.Log("I'm created");
}

public T curState{
get{
public T curState
{
get
{
return _curState;
}
set{
if (!(value.Equals(_curState))){
set
{
if ( !(value.Equals(_curState))){
StateMachine<T>.OnStateChange.Say(_curState, value);
_curState = value;
}
}

}

public void resetState(T noneState){
T transientState_ = _curState;
public void resetState(T noneState)
{
T transientState = _curState;
StateMachine<T>.OnStateChange.Say(_curState, noneState );
_curState = noneState;
_curState = transientState_;
_curState = transientState;
}
}
File renamed without changes.
@@ -4,12 +4,13 @@

public class ShotForceEvaluator : MonoBehaviour {

public float startRadius;
public float shotForceMax;
public float StartRadius;
public float ShotForceMax;

private Vector2 _pos2D;
private Vector2 _startPos;
private Vector2 _touchPos;
private Vector2 _curPos;
private float _shotForce;
private bool _isStarted = false;

@@ -23,8 +24,8 @@ void Awake()
if (Input.GetMouseButtonDown(0))
{
_startPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

if ((Vector2.SqrMagnitude(_startPos - _pos2D)) > startRadius)
_curPos = _startPos;
if (!((Vector2.SqrMagnitude(_startPos - _pos2D)) > StartRadius))
{
_isStarted = false;
}
@@ -36,12 +37,20 @@ void Awake()

if (_isStarted)
{

if (Input.GetMouseButton(0))
{

_touchPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
_shotForce = Mathf.Min(Vector2.Distance(_touchPos, _startPos)*2, shotForceMax);
Controller.demoFire.Say(_shotForce);
Controller.fillRadialElement.Say(_shotForce/shotForceMax);
if (_touchPos != _curPos)
{
_curPos = _touchPos;
_shotForce = Mathf.Min(Vector2.Distance(_touchPos, _startPos)*2, ShotForceMax);
Controller.demoMissileDestroy.Say();
Controller.demoFire.Say(_shotForce);
Debug.Log(_shotForce/ShotForceMax);
Controller.fillRadialElement.Say(_shotForce/ShotForceMax);
}
}

if (Input.GetMouseButtonUp(0))
@@ -15,27 +15,23 @@ public class TrailHandler : MonoBehaviour {
_trails[1] = new List<GameObject>();
_trails[2] = new List<GameObject>();

TrailMaker.trail.Subscribe(addTrail);
TrailMaker.Trail.Subscribe(addTrail);

}

void addTrail(List<GameObject> trail)
{
deleteTrail(_trails[_count]);
_trails[_count] = trail;
Debug.Log("Added");
//_count++;



//Debug.Log("Added");
}

public List<Vector2> getPath()
{
List<Vector2> path = new List<Vector2>();
foreach (GameObject point in _trails[_count])
{
path.Add(point.transform.position);

path.Add(point.transform.position);
}
return path;
}
@@ -48,7 +44,7 @@ void deleteTrail(List<GameObject> trail)

Destroy(dot);
}
Debug.Log("Destroyed");
//Debug.Log("Destroyed");
trail.Clear();
//_count--;
}