<commit_before>﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public enum ConstelationType {
	ATTACK,
	DEFENCE,
	HEAL
}

[System.Serializable]
public struct ConstelationNode  {
	public ConstelationStar star;
	public List<ConstelationStar> links;
}

public class Constelation : MonoBehaviour {

	public List<ConstelationNode> constelation;
	// Use this for initialization

	public ConstelationStar startStar= null;

	public UnityEngine.UI.Image ConstelationImage;

	public float maxAlpha= 30f;
	public float NBActivateStar = 0;
	public float NBStar = 0;

	public float TimeAtOver = 2f;

	private IEnumerator FadeEnumeration = null;
	void Start () {
		foreach (ConstelationNode c in constelation) {
			NBStar++;
			c.star.starConstelation = this;
		}
	}
	
	// Update is called once per frame
	void Update () {
		if (startStar != null && !Input.GetMouseButton(0) && NBActivateStar != NBStar) {
			destructConstelation ();
		}
	}

	void UpdateActivateStar(){
		if (NBActivateStar == NBStar) {
			ConstelationFinish ();
		}

		float percent = NBActivateStar / NBStar;
		if (FadeEnumeration != null) {
			StopCoroutine (FadeEnumeration);
		}
		FadeEnumeration = FadeTo (percent*maxAlpha, 1.0f);
		
		StartCoroutine(FadeEnumeration);
	}

	IEnumerator FadeTo(float aValue, float aTime)
	{
		float alpha = ConstelationImage.color.a;
		for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / aTime)
		{
			Color newColor = new Color(1, 1, 1, Mathf.Lerp(alpha,aValue,t));
			ConstelationImage.color = newColor;
			yield return null;
		}
	}

	IEnumerator DestructIn( float aTime)
	{
		for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / aTime)
		{
			yield return null;
		}
		destructConstelation ();
	}
	void ConstelationFinish() {
		foreach (ConstelationNode c in constelation) {
			c.star.state = StarStates.OVER;
		}
		StartCoroutine(DestructIn( TimeAtOver));

	}

	void destructConstelation (){
		//TODO destroyConstellation
		foreach (ConstelationNode c in constelation) {
			c.star.state = StarStates.IDLE;
		}
		startStar = null;
		NBActivateStar = 0;
		UpdateActivateStar ();
	}
		<commit_msg>mouse + constellation type and strength<commit_after>﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public enum ConstelationType {
	ATTACK,
	DEFENCE,
	HEAL
}

[System.Serializable]
public struct ConstelationNode  {
	public ConstelationStar star;
	public List<ConstelationStar> links;
}

public class Constelation : MonoBehaviour {

	public List<ConstelationNode> constelation;
	// Use this for initialization

	public ConstelationStar startStar= null;

	public UnityEngine.UI.Image ConstelationImage;

	public ConstelationType constelationType = ConstelationType.ATTACK;
	public int constelationStrength = 2;

	public float maxAlpha= 30f;
	public float NBActivateStar = 0;
	public float NBStar = 0;

	public float TimeAtOver = 2f;

	private IEnumerator FadeEnumeration = null;
	void Start () {
		foreach (ConstelationNode c in constelation) {
			NBStar++;
			c.star.starConstelation = this;
		}
	}
	
	// Update is called once per frame
	void Update () {
		if (startStar != null && !Input.GetMouseButton(0) && NBActivateStar != NBStar) {
			destructConstelation ();
		}
		if (startStar != null && Input.GetMouseButton (0)) {
		
			Vector3 mousePosition = Input.mousePosition;
			Vector3 pz = Camera.main.ScreenToWorldPoint(Input.mousePosition);
			pz.z = 0;
			// DEBUG startStar.transform.position = pz;

		//TODO draw line between mouse and star
		}
	}

	void UpdateActivateStar(){
		if (NBActivateStar == NBStar) {
			ConstelationFinish ();
		}

		float percent = NBActivateStar / NBStar;
		if (FadeEnumeration != null) {
			StopCoroutine (FadeEnumeration);
		}
		FadeEnumeration = FadeTo (percent*maxAlpha, 1.0f);
		
		StartCoroutine(FadeEnumeration);
	}

	IEnumerator FadeTo(float aValue, float aTime)
	{
		float alpha = ConstelationImage.color.a;
		for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / aTime)
		{
			Color newColor = new Color(1, 1, 1, Mathf.Lerp(alpha,aValue,t));
			ConstelationImage.color = newColor;
			yield return null;
		}
	}

	IEnumerator DestructIn( float aTime)
	{
		for (float t = 0.0f; t < 1.0f; t += Time.deltaTime / aTime)
		{
			yield return null;
		}
		destructConstelation ();
	}


	void ConstelationFinish() {
		foreach (ConstelationNode c in constelation) {
			c.star.state = StarStates.OVER;
		}
		StartCoroutine(DestructIn( TimeAtOver));
		//TODO set value to player
	}

	void destructConstelation (){
		//TODO destroyConstellation
		foreach (ConstelationNode c in constelation) {
			c.star.state = StarStates.IDLE;
		}
		startStar = null;
		NBActivateStar = 0;
		UpdateActivateStar ();
	}
		
{'fraction_non_alphanumeric': 0.10277185501066098, 'fraction_numerical': 0.009594882729211088, 'mean_word_length': 3.927521008403361, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7379842', 'n_tokens_mistral': 1816, 'n_tokens_neox': 1607, 'n_words': 396}