Orientation isEnemyZoneCollide()
    {
        List <Vector2> pointsList = GameController.Inst.GetEnemyZone();

        for (int i = 0; i < pointsList.Count; i++)
        {
            int    nextIndex = (i < pointsList.Count - 1) ? i + 1 : 0;
            myLine line      = new myLine()
            {
                StartPoint = pointsList[i], EndPoint = pointsList[nextIndex]
            };
            if (LineHelper.isVectorIntersect(transform.position, line, 0.02f))
            {
                if ((line.StartPoint.x - line.EndPoint.x) < 0.2f && (line.StartPoint.x - line.EndPoint.x) > -0.2f)
                {
                    return(Orientation.Vertical);
                }
                else if ((line.StartPoint.y - line.EndPoint.y) < 0.2f && (line.StartPoint.y - line.EndPoint.y) > -0.2f)
                {
                    return(Orientation.Horizontal);
                }
            }
        }
        if (!LineHelper.IsPointInPolygon(pointsList, transform.position))
        {
            return(Orientation.Vertical);
        }
        return(Orientation.NONE);
    }
예제 #2
0
    /// <summary>
    /// This Update is responsible for cheking is player in collider;
    /// </summary>
    void FixedUpdate()
    {
        Vector3 newPos = GetPlayerPos();

        if (playerPosition != newPos)
        {
            bool isInPoligon = LineHelper.IsPointInPolygon(zoneManager.currentPosArray, newPos);
            if (!isDrawingNewZone && isInPoligon)
            {
                isDrawingNewZone = true;

                if (onStartMoving != null)
                {
                    onStartMoving(newPos);
                }
            }
            if (isDrawingNewZone && !isInPoligon)
            {
                isDrawingNewZone = false;

                if (onEndMoving != null)
                {
                    onEndMoving(newPos);
                }
                player.StopMoving();
            }
            playerPosition = newPos;
        }
    }
    private void GameManager_onScoreUpdate()
    {
        List <GameObject> wait4Remove = new List <GameObject>();

        for (int i = 0; i < activatedWaterEnemies.Count; i++)
        {
            if (!LineHelper.IsPointInPolygon(GameController.Inst.GetEnemyZone(), activatedWaterEnemies[i].transform.position))
            {
                activatedWaterEnemies[i].SetActive(false);
                waitWaterEnemies.Add(activatedWaterEnemies[i]);
                wait4Remove.Add(activatedWaterEnemies[i]);
            }
        }
        foreach (GameObject go in wait4Remove)
        {
            activatedWaterEnemies.Remove(go);
        }
        if (activatedWaterEnemies.Count == 0)
        {
            GameController.Inst.LevelUp();
        }
    }