Exemplo n.º 1
0
    // Use this for initialization
    protected virtual void Awake()
    {
        movingController = GetComponent<MovingController>();
        opponentRenderer.material.color = mainColor;

        // set it on random location
        if (transform.rotation.eulerAngles == Vector3.zero)
        {
            do
            {
                transform.rotation = Quaternion.Euler(Random.Range(0f, 360f), 0f, Random.Range(0f, 360f));
            } while (transform.rotation.eulerAngles == Vector3.zero);
        }

        // set random intensity
        if (moveIntensity == Vector2.zero)
        {
            SetRandomMoveIntensity();
        }
    }
Exemplo n.º 2
0
    void Awake()
    {
        _camera = FindObjectOfType <Camera>();

        _deltaCameraCharacter = Camera.main.orthographicSize / 5;
        _lvlWidth             = Camera.main.orthographicSize * 2.0f * Camera.main.aspect;

        _gameLogic = FindObjectOfType <GameLogic>();

        _movingController = GetComponent <MovingController>();
        _movingController.SetForceCoef(_characterData.ForceJumpCoef);
        _movingController.SetFlyingSpeed(_characterData.FlyingSpeed);

        _attackController = GetComponent <AttackController>();

        _rigidbody = GetComponent <Rigidbody2D>();
        _ui        = FindObjectOfType <InGameUi>();
        _visual    = GetComponent <Visual>();


        _armorCoroutine   = ArmorLogic();
        _magnetCoroutine  = MagnetLogic();
        _jetpackCoroutine = JetpackLogic();
    }
 void GetMainCategoryId()
 {
     MovingController movingController = GetComponent <MovingController>();
     //mainCategoryId = movingController.GetCategoryId();
 }
Exemplo n.º 4
0
    //  we need to know which shape's directions we need to change
    public void GetTheShapeToChangeItsDirections(GameObject shape)
    {
        shapeToChangeDirections = shape;
//		Debug.Log (shapeToChangeDirections.name);
        mC = (MovingController)shapeToChangeDirections.GetComponent(typeof(MovingController));
    }
Exemplo n.º 5
0
    private void Update()
    {
        _audi.volume = gameManager.soundVolume;

        MovingController controller = Player.GetComponent <MovingController>();

        if (mainFire.buildingLevel > 0 &&
            Vector2.Distance(transform.position, Player.transform.position) < 1.8f && !cutDown && Mathf.Abs(controller.speedX) < 8 &&
            controller.health > 0)
        {
            HintText.text  = BuildText;
            HintText.color = new Color(1, 1, 1, 1);
            onetime        = true;
            if (Input.GetKeyDown(KeyCode.E))
            {
                mainFire.workManager.TreesToAxe.Add(this);
                SR.sprite = MarkedTree;
                cutDown   = true;
            }
        }
        else
        {
            TextOff();
        }
        if (cutDown)
        {
            if (progress < 100)
            {
                if (axing)
                {
                    if (axingTimer > 0)
                    {
                        axingTimer -= Time.deltaTime;
                    }
                    else
                    {
                        _audi.PlayOneShot(AxingSounds[axingI]);
                        if (axingI < AxingSounds.Length - 1)
                        {
                            axingI++;
                        }
                        else
                        {
                            axingI = 0;
                        }
                        axingTimer = 0.88f;
                    }


                    progress += Time.deltaTime * 15f;
                }
            }
            else
            {
                if (!onetimeList)
                {
                    mainFire.workManager.treeI = 0;
                    mainFire.workManager.ponyI = 0;
                    mainFire.workManager.TreesToAxe.Remove(this);
                    onetimeList = true;
                }

                crown.timerLanding = 0f;
                crown.LandingPositions.Remove(this);
                if (leftTree)
                {
                    squirrels.LeftTrees.Remove(transform);
                }
                else
                {
                    squirrels.RightTrees.Remove(transform);
                }

                Squirrel tempSq = squirrels.FindSquirrelByTree(transform);
                if (tempSq != null)
                {
                    tempSq.newtree = null;
                }

                TextOff();
                if (Down())
                {
                    if (!onetimeAddTree)
                    {
                        if (myForest != null)
                        {
                            myForest.myTrees--;
                        }
                        Item newWood = PoolManager.getGameObjectFromPool(WoodPrefab).GetComponent <Item>();
                        newWood.GetComponent <SpriteRenderer>().sprite = newWood.woodSprite;
                        newWood.player             = Player;
                        newWood.transform.position = new Vector2(transform.position.x, transform.position.y - 0.2f);
                        newWood.woodCount          = wood;
                        resourses.SaveItems.Add(newWood);
                        onetimeAddTree = true;
                    }
                    if (!_audi.isPlaying)
                    {
                        gameObject.SetActive(false);
                    }
                }
            }

            if (Worker != null && Worker.work != this)
            {
                Worker = null;
            }
        }
    }
Exemplo n.º 6
0
 void Start()
 {
     mc = GetComponent <MovingController> ();
 }
Exemplo n.º 7
0
    public void CheckUpdateTwo()
    {
        MovingController controller = Player.GetComponent <MovingController>();

        if (!hintOff && Vector2.Distance(Player.transform.position, transform.position) < 2f && Mathf.Abs(controller.speedX) < 8 &&
            controller.health > 0)
        {
            if (timerWood > 0)
            {
                if (weather.weatherNumber >= 8)
                {
                    HintText.text = "Нельзя строить во время дождя";
                }
                else if (!weather.timeCount.isDay)
                {
                    HintText.text = "Нельзя строить ночью";
                }
                else
                {
                    HintText.text = "Не хватает древесины";
                }
                timerWood -= Time.deltaTime;
            }
            else
            {
                if (needWoodUpdateTwo > 0)
                {
                    HintText.text = UpdateTwoText + ", " + needWoodUpdateTwo + " древесины";
                }
                else
                {
                    HintText.text = UpdateTwoText;
                }
            }

            HintText.color = new Color(1, 1, 1, 1);
            onetimeHint    = true;

            if (Input.GetKeyDown(KeyCode.E))
            {
                if (resourses.Wood >= needWoodUpdateTwo && weather.weatherNumber < 8 && weather.timeCount.isDay)
                {
                    onetime       = true;
                    startBuilding = true;
                    hintOff       = true;
                }
                else
                {
                    timerWood = 0.7f;
                }
            }
        }
        else
        {
            if (onetimeHint)
            {
                timerWood      = 0;
                HintText.color = new Color(1, 1, 1, 0);
                onetimeHint    = false;
            }
        }
    }