Exemple #1
0
    public static bool AnyInRange(Vector3 position, float range, Vector3[] search, ref bool[] isInRange)
    {
        Vector3[] a = search;//GlobalPOI.poi.ToArray();
        bool      anyPointsFound = false;

        if (isInRange.Length != a.Length)
        {
            isInRange = new bool[a.Length];
        }

        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] == null)
            {
                isInRange[i] = false;
                continue;
            }
            if (MovingCharacter.SqDistance(position, a[i]) < Mathf.Pow(range, 2))
            {
                isInRange[i]   = true;
                anyPointsFound = true;
            }
            else
            {
                isInRange[i] = false;
            }
        }
        return(anyPointsFound);
    }
    /// <summary>
    /// Destroy speed donut if it's lifetime is over.  
    /// </summary>
    void Update()
    {

        if (!isInitialized)
        {
            GameObject gameControllerObject = GameObject.FindWithTag("GameController");
            if (gameControllerObject != null)
            {
                gameController = gameControllerObject.GetComponent<GameController>();
            }
            if (gameController == null)
            {
                Debug.Log("Can't find gameController script!!!");
            }
            GameObject player = GameObject.FindWithTag("Player");
            if (player != null)
            {
                playerController = player.GetComponent<MovingCharacter>();
            }
            if (playerController == null)
            {
                Debug.Log("Can't find PlayerMovement script!!!");
            }

            isInitialized = true;
        }

        time += Time.deltaTime;
        if (time >= lifeTime && !isBoosting)
        {
            Object.Destroy(gameObject);
        }
    }
 void Start()
 {
     spriteRenderer   = GetComponent <SpriteRenderer>();
     HP               = maxHP;
     movingChar       = GetComponent <MovingCharacter>();
     floatingText     = GameManager.instance.floatingText;
     originalMaterial = spriteRenderer.material;
 }
Exemple #4
0
 public void PartyFollow(MovingCharacter c, int a)
 {
     if (a < PMs.Length && PMs[a] != null)
     {
         PMs[a].Move(c.lastLocation);
         PartyFollow(PMs[a], a + 1);
     }
     return;
 }
    private void OnTriggerEnter(Collider other)
    {
        // If moving character enters, teleport them to exit
        MovingCharacter character = other.GetComponent <MovingCharacter>();

        if (character != null)
        {
            other.transform.position = Exit.transform.position;
            Exit.TeleportEffect.Play();
        }
    }
Exemple #6
0
 internal static void AddToFilter(ref bool[] filter, MovingCharacter add, bool pass)
 {
     for (int i = 0; i < worldCrowd.Count; i++)
     {
         if (worldCrowd[i] == add)
         {
             filter[i] = pass;
             break;
         }
     }
 }
Exemple #7
0
    void Start()
    {
        target = GameObject.FindGameObjectWithTag(TargetPlayer).transform;
        player = target.GetComponent <PlayerController>();

        motor = GetComponent <MovingCharacter>();

        animator = GetComponent <Animator>();
        animator.SetBool(AnimationAtack, false);

        EnemyRandomSkin();
    }
Exemple #8
0
 public CharacterDataHolder(MovingCharacter c)
 {
     _health               = c.getHealth();
     _moveList             = c.moveList;
     _characterSpeedFactor = c.characterSpeedFactor;
     _experience           = c.experience;
     _level = c.level;
     _x     = c.transform.position.x;
     _y     = c.transform.position.y;
     _name  = c.name;
     _team  = c.getTeam();
     _animX = c.animX;
     _animY = c.animY;
 }
    public override void ApplyFix(ref Vector3 dir, Vector3 pos)
    {
        // keeps distance to allies by taking nearest 2
        MovingCharacter[] participants = GlobalCrowds.Participants();
        // TODO: apply right or left vectors based on distance to crowd and their direction, prefering right
        Vector3         fix     = Vector3.zero;
        MovingCharacter nearest = GlobalCrowds.ChoseNearest(transform);

        if (nearest)
        {
            Vector3 neardir = nearest.transform.position - transform.position;
            if (keepRangeToAllies == 0)
            {
                Debug.Log("Range is 0.", this);
            }
            if (Vector3.Distance(nearest.transform.position, transform.position) < keepRangeToAllies)
            {
                fix += -neardir;
                NextRange();
            }

            /*
             * bool[] filter = new bool[GlobalCrowds.worldCrowd.Count];
             * for (int i = 0; i < filter.Length; i++) {
             *  filter[i] = true;
             * }
             * GlobalCrowds.AddToFilter(ref filter, nearest, false);
             * MovingCharacter secondNearest = GlobalCrowds.ChoseNearest(transform, filter);
             * // find path to near and secnear, add negative vectors of them to fix and normalize
             * // you get a vector pointing away from 2 nearest units
             * if (secondNearest != null) {
             *  Vector3 secndir = secondNearest.transform.position - transform.position;
             *  fix += -secndir;
             *  Debug.Log("test2 "+fix);
             * }*/
        }

        dir = (dir + fix).normalized;
        base.ApplyFix(ref dir, pos);
    }
Exemple #10
0
    void OnGUI()
    {
        GUI.skin = modernGUISkin;
        if (!isStarted)
        {
            GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            GUILayout.Label("Press Start Button");

            if (GUILayout.Button("Start"))
            {
                isStarted = true;
                StartGame();
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndArea();
        }

        // 끝날 때
        else if (isEnded)
        {
            GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            GUILayout.Label("You rescue the pretty Bunny! :D");
            int totalScore = ScoreManager.getScore() + (MovingCharacter.getHealth() * 2000);
            GUILayout.Label("Your Score : " + totalScore.ToString());

            if (GUILayout.Button("Restart?"))
            {
                ScoreManager.initScore();
                SceneManager.LoadScene("Stage1", LoadSceneMode.Single);
                isEnded = false;
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndArea();
        }

        // 죽었을 때
        else if (isRestart)
        {
            GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            GUILayout.Label("Oh! You die... But you Can Restart!");

            if (GUILayout.Button("Restart?"))
            {
                ScoreManager.initScore();
                SceneManager.LoadScene("Stage1", LoadSceneMode.Single);
                isRestart = false;
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.EndArea();
        }
    }
 void Start()
 {
     spriteRenderer = GetComponent<SpriteRenderer>();
     HP = maxHP;
     movingChar = GetComponent<MovingCharacter>();
     floatingText = GameManager.instance.floatingText;
     originalMaterial = spriteRenderer.material;
 }
Exemple #12
0
 internal static void AddParticipant(MovingCharacter movingCharacter)
 {
     worldCrowd.Add(movingCharacter);
 }
Exemple #13
0
 // Use this for initialization
 void Start()
 {
     m_movingCharacter = gameObject.GetComponent <MovingCharacter>();
     cam.Player        = this;
 }