Exemplo n.º 1
0
    //Генерує сферу, якщо попередня виходить за межі колайдера спавна (респавн повинен мати статичний колайдер!)
    void OnTriggerExit2D(Collider2D previos)
    {
        if (CountOfBalls <= ballCount && !IsInfiniteLaunch)
        {
            previos.GetComponent <BallBehaviour>().IsLastBallInResp = true;
            previos.tag = "ball";
            return;
        }

        if (previos.tag != "newBall")
        {
            return;
        }

        TypesSphere typeSphere = ballCreator.randomType(true, CountColor);
        GameObject  ball       = ballCreator.getBall(ballTransform, transform.position, typeSphere).gameObject;

        ballBehaviour = ball.GetComponent <BallBehaviour>();
        BallController.BallsLists[4].Add(ball);
        SetBallPropertis(); // перша сфера
        ballCount++;
        previos.tag = "ball";
        //previos.gameObject.GetComponent<CircleCollider2D>().isTrigger = true;
        // previos.GetComponent<BallBehaviour>().Health = 0;
        // previos.GetComponent<BallBehaviour>().Health = 0;

        // previos.GetComponent<BallBehaviour>().Stop();
    }
    void FixedUpdate()
    {
        //ДЕБАГ
        if (BackBall != null)
        {
            backType = BackBall.GetComponent <SphereBehaviour>().TypeSphere;
        }
        else
        {
            backType = TypesSphere.EMPTY;
        }

        if (FrontBall != null)
        {
            forwardType = FrontBall.GetComponent <SphereBehaviour>().TypeSphere;
        }
        else
        {
            forwardType = TypesSphere.EMPTY;
        }
        if (FrontBall != null && BackBall != null)
        {
            if (FrontBall == BackBall)
            {
                Debug.LogError("FrontBall == BackBall: " + FrontBall.GetComponent <SphereBehaviour>().TypeSphere);
                Destroy(gameObject);
            }
        }
        //ДЕБАГ

        Muving();
    }
Exemplo n.º 3
0
    void Start()
    {
        // Debug.Log("-=3=-");
        //  BallController.RedyToRunNewPlayerBall = false;

        if (explosiveBallTransform == null)
        {
            Debug.LogError("explosiveBallTransform==null");
        }
        //Завантажити збереження
        saveLoadManager = new SaveLoadGame();
        save            = saveLoadManager.LoadSave();
        Debug.Log(save.curLvl);

        // створити мапу, відповідно до рівня та отримати її скрипт
        map    = createMapGameobject(save.curLvl).GetComponent <MapInfo>();
        player = map.player;

        TextUpdate();
        LevelPreference(save.curLvl);

        TypesSphere typeSphere = ballCreator.randomType(true, CountColor);

        newSphere = ballCreator.getBall(ballTransform, map.pointToRespawnPlayersBall.position, typeSphere).gameObject;
        // newSphere.GetComponent<BallBehaviour>().TypeSphere = typeSphere;
        //  destroyLists = BallController.BallsLists;
    }
Exemplo n.º 4
0
    void OnMouseDown()
    {
        /*if (launchSphere == null)
         * {
         *  BallController.RedyToRunNewPlayerBall = true;
         * }
         * else if (launchSphere.tag != "player")
         *  BallController.RedyToRunNewPlayerBall = true;*/

        if (!BallController.RedyToRunNewPlayerBall)
        {
            return;
        }

        //Debug.Log("-=2=-");
        BallController.RedyToRunNewPlayerBall = false;

        if (moveTo == null)
        {
            Debug.Log("не вказаний moveTo об'єкт в редакторі");
            return;
        }

//      moveToPos.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z));
        moveTo.position = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
        moveTo.position = new Vector3(moveTo.position.x - map.player.transform.position.x, moveTo.position.y - map.player.transform.position.y, 0);

        //Debug.Log("coord X=" + moveTo.position.x);
        //Debug.Log("coord Y=" + moveTo.position.y);
        //Vector3 relativePos = moveTo.position - player.transform.position;
        // transform.rotation = Quaternion.LookRotation(player.transform.forward, relativePos);
        // player.transform.LookAt((new Vector3(moveTo.position.x, moveTo.position.y, player.transform.position.z ));
        player.transform.rotation    = Quaternion.LookRotation(transform.forward, new Vector3(moveTo.position.x, moveTo.position.y, player.transform.position.z));
        newSphere.transform.position = map.pointToRespawnPlayersBall.position;
        //newSphere.tag = "player";
        SphereBehaviour sb = newSphere.GetComponent <SphereBehaviour>();

        sb.Speed = Speed;
        sb.Move(moveTo);
        launchSphere = newSphere;

        //Звук
        if (launchBallSound != null)
        {
            launchBallSound.Play();
        }

        TypesSphere typeSphere = ballCreator.randomType(true, CountColor);

        newSphere = ballCreator.getBall(ballTransform, map.pointToRespawnPlayersBall.position, typeSphere).gameObject;
        sb        = newSphere.GetComponent <SphereBehaviour>();
        //sb.TypeSphere = typeSphere;
        //Debug.Log(sb.TypeSphere);
        // newSphere = null;                   //прибрати
    }
Exemplo n.º 5
0
    //Повертає шар певного кольору
    public Transform getBall(Transform ball,           //який об'єкт створювати
                             Vector3 placeToCreate,    //в якій позиції
                             TypesSphere typeBall)     //якого кольору(чи іншого типу для некольорового)
    {
        Transform result = Transform.Instantiate(ball, placeToCreate, Quaternion.identity);

        SphereBehaviour sb = result.gameObject.GetComponent <SphereBehaviour>();

        sb.TypeSphere = typeBall;

        result.GetComponent <Renderer>().material.color = GetColorByType(typeBall);
        return(result);
    }
Exemplo n.º 6
0
    public void OnButtonMulticolor()
    {
        if (save.curCountMulticolor < 1)
        {
            return;
        }

        Destroy(newSphere);
        TypesSphere typeSphere = TypesSphere.MULCOLOR;

        newSphere = ballCreator.getBall(multicolorBallTransform, map.pointToRespawnPlayersBall.position, typeSphere).gameObject;
        BallMulticolor advencedBall = newSphere.GetComponent <BallMulticolor>();

        advencedBall.powerMulticolorSkill = save.skill[(int)PlayerSkill.SK_MULTICOLOR_POWER];

        Debug.Log("newSphere type=" + newSphere.GetComponent <BallBehaviour>().TypeSphere);
        save.curCountMulticolor--;
    }
Exemplo n.º 7
0
    public void OnButtonExplosive()
    {
        if (save.curCountExplosive < 1)
        {
            return;
        }

        Destroy(newSphere);
        TypesSphere typeSphere = TypesSphere.EXPLOSIVE;

        newSphere = ballCreator.getBall(explosiveBallTransform, map.pointToRespawnPlayersBall.position, typeSphere).gameObject;

        BallExplosive advencedBall = newSphere.GetComponent <BallExplosive>();

        advencedBall.rangExplosiveSkill = save.skill[(int)PlayerSkill.SK_BONUS_EXP];
        advencedBall.scoreMessage      += AddScore;

        save.curCountExplosive--;
    }
Exemplo n.º 8
0
    public void OnButtonBeaver()
    {
        if (save.curCountBeaver < 1)
        {
            return;
        }

        Destroy(newSphere);
        TypesSphere typeSphere = TypesSphere.BEAVER;

        newSphere = ballCreator.getBall(beaverBallTransform, map.pointToRespawnPlayersBall.position, typeSphere).gameObject;

        BallBeaver advencedBall = newSphere.GetComponent <BallBeaver>();

        advencedBall.PowerBeaverSkill = save.skill[(int)PlayerSkill.SK_BEAVER_POWER];
        advencedBall.scoreMessage    += AddScore;

        save.curCountBeaver--;
    }
Exemplo n.º 9
0
    void Start()
    {
        ballCreator = new BallCreator();

        foreach (var triger in accTrigger)
        {
            triger.triggerMessage += OnAccTriggerEvent;
        }
        //stopTrigger.triggerMessage += OnStopTriggerEvent;

        BallController.blockPlayer = true;
        Speed = 7.0f;
        //isStartVelocity = true;

        //BallController.AddBallsList(balls, RespID);
        TypesSphere typeSphere = ballCreator.randomType(true, CountColor);
        GameObject  ball       = ballCreator.getBall(ballTransform, transform.position, typeSphere).gameObject;

        ballBehaviour = ball.GetComponent <BallBehaviour>();
        BallController.BallsLists[4].Add(ball);
        SetBallPropertis(); // перша сфера
        ballCount++;
    }
Exemplo n.º 10
0
    private Vector4 GetColorByType(TypesSphere typeBall)
    {
        Vector4 color;

        switch (typeBall)
        {
        case TypesSphere.RED:
        {
            color = Color.red;
            break;
        }

        case TypesSphere.GREEN:
        {
            color = Color.green;
            break;
        }

        case TypesSphere.BLUE:
        {
            color = Color.blue;
            break;
        }

        case TypesSphere.YELLOW:
        {
            color = Color.yellow;
            break;
        }

        case TypesSphere.PURPLE:
        {
            color = new Vector4(1, 0, 1, 1);
            break;
        }

        /* case TypesSphere.EXPLOSIVE:
         *   {
         *       Debug.Log("TypesSphere.EXPLOSIVE");
         *       color = Color.black;
         *       break;
         *   }*/
        case TypesSphere.BEAVER:
        {
            color = Color.gray;
            break;
        }

        case TypesSphere.EMPTY:
        {
            color = new Vector4(1, 1, 1, 0);
            break;
        }

        default:
        {
            color = Color.white;         // за замовчуванням білий, непрозорий
            break;
        }
        }
        return(color);
    }
Exemplo n.º 11
0
 //Зміна кольору кулі
 public void ChengeColor(GameObject ball, TypesSphere typeBall)
 {
     ball.transform.GetComponent <Renderer>().material.color = GetColorByType(typeBall);
 }