Ejemplo n.º 1
0
    public void SpawnNewTarget()
    {
        mainTarget      = Instantiate <GameObject>(Resources.Load <GameObject>("Soldier")).GetComponent <HostFigure>();
        mainTarget.name = "Trump";
        Vector3 randomPos = new Vector3(Random.Range(spawnableArea.min.x, spawnableArea.max.x), Random.Range(spawnableArea.min.y, spawnableArea.min.y), 0);
        int     tries     = 0;

        while ((randomPos - player.transform.position).sqrMagnitude < 1300 && tries < 100)
        {
            ++tries;
            randomPos = new Vector3(Random.Range(spawnableArea.min.x, spawnableArea.max.x), Random.Range(spawnableArea.min.y, spawnableArea.min.y), 0);
        }
        if (tries == 100)
        {
            Debug.LogError("Oh hell");
        }

        mainTarget.transform.localPosition = randomPos;
        mainTarget.Init(HostFigureType.Trump);

        targetPointer = (Instantiate(Resources.Load("TargetPointer")) as GameObject).GetComponent <OffscreenPointer> ();
        targetPointer.transform.parent = transform;

        targetPointer.Init(mainTarget.transform, player.transform);

        leaderAnimationShown = true;
        DisplayLeaderSequence();
    }
Ejemplo n.º 2
0
    public void OnHostFigureInfected(HostFigure hf)
    {
        if (hf.hostType == HostFigureType.Trump)
        {
            Destroy(player.GetComponent <Flingable> ());
        }
        else
        {
            score += 1;
            if (score <= powerMax)
            {
                ShowFloatingPowerText(hf.transform.position + Vector3.up * 2, score.ToString(), 0.8f, true, true);
            }

            if (score == powerMax && targetPointer == null)
            {
                foreach (GameObject floatingLabel in floatingLabels)
                {
                    Destroy(floatingLabel);
                }
                ShowFloatingText(player.transform.position + Vector3.up * 3, "MAX POWER, ATTACK!", 0.8f, false, true, 1, true);
                SpawnNewTarget();
            }
            else if (score == powerMax)
            {
                ShowFloatingText(player.transform.position + Vector3.up * 3, "MAX POWER, ATTACK!", 0.8f, false, true, 1);
            }

            score = Mathf.Min(score, powerMax);
        }

        //UpdateComboCounter (hf.transform.position + Vector3.up * 3f);
//        if (comboCounter % 5 == 0 && comboCounter > 0)
//            ShowFloatingText (player.transform.position + Vector3.up * 3, "AWESOME! +" + 5, 0.8f, false, true);
    }
Ejemplo n.º 3
0
 void LeaveHost()
 {
     if (currentHost != null)
     {
         previousHost = currentHost;
         healthbar.Init(3.5f);
         currentHost.healthBar.healthLeft = 0;
         currentHost = null;
     }
 }
Ejemplo n.º 4
0
    public void SpawnNewSoldier(Vector3 position)
    {
        GameObject hostFigureGO = Instantiate(m_hostFigurePrefab) as GameObject;

        hostFigureGO.transform.localPosition = position;
        HostFigure hostFigure = hostFigureGO.GetComponent <HostFigure>();

        hostFigure.Init(HostFigureType.Soldier);
        hostFigures.Add(hostFigure);
    }
Ejemplo n.º 5
0
 void SetHost(HostFigure newHost)
 {
     currentHost = newHost;
     DOTween.Kill(spriteTransform);
     transform.parent           = newHost.visualContainer;
     spriteTransform.localScale = Vector3.zero;
     transform.localPosition    = Vector3.zero;
     body.velocity = Vector2.zero;
     isFlying      = false;
     healthbar.Disable();
 }
Ejemplo n.º 6
0
 public void OnHostFigureDie(HostFigure hf)
 {
     hostFigures.Remove(hf);
     if (hf.wasTrump)
     {
         DOVirtual.DelayedCall(1.5f, () => {
             gameOverScreen.Show(true);
         });
     }
     if (hf.isBoss)
     {
         BossPhaseEnd();
     }
 }
Ejemplo n.º 7
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (currentHost != null)
        {
            return;
        }

        HostFigure hostHit = other.GetComponentInParent <HostFigure> ();

        if (hostHit != null && !hostHit.isDead && (previousHost == null || hostHit != previousHost))
        {
            Vector2 knockBackForce = body.velocity.normalized;
            knockBackForce *= Mathf.Clamp(body.velocity.magnitude / 5, 0, 3);
            hostHit.OnHit(knockBackForce);
            if (!hostHit.isBoss)
            {
                SetHost(hostHit);
            }
        }
    }
Ejemplo n.º 8
0
    public void Animation(HostFigure hostFigure, System.Action callback)
    {
        topBGHiddenPos    = topBG.transform.localPosition;
        bottomBGHiddenPos = bottomBG.transform.localPosition;
        imageHiddenPos    = image.transform.localPosition;
        textHiddenPos     = text.transform.localPosition;

        DOTween.Kill(Camera.main, false);

        GameManager.Instance.scoreText.gameObject.SetActive(false);
        GameManager.Instance.targetPointer.gameObject.SetActive(false);

        mac.transform.parent        = null;
        mac.transform.localScale    = Vector3.one;
        mac.transform.localPosition = new Vector3(hostFigure.transform.localPosition.x, hostFigure.transform.localPosition.y + GameManager.SCREEN_HEIGHT);

        smokePS.transform.parent        = null;
        smokePS.transform.localPosition = new Vector3(hostFigure.transform.localPosition.x, hostFigure.transform.localPosition.y - 0.5f);

        Vector3 cameraPos = Camera.main.transform.localPosition;

        DOTween.Sequence().Insert(0f,
                                  DOTween.To(value => Time.timeScale = value, 1, 0, 0.3f).SetEase(Ease.InCubic)
                                  ).InsertCallback(0.4f, () => {
            DOTween.Kill(Camera.main.transform, false);
            Camera.main.transform.DOLocalMove(new Vector3(hostFigure.transform.localPosition.x, hostFigure.transform.localPosition.y, Camera.main.transform.localPosition.z), 1f).SetUpdate(UpdateType.Normal, true);
        }).InsertCallback(0.8f, () => {
            DOTween.Kill(Camera.main, false);
            Camera.main.DOOrthoSize(6, 0.6f).SetEase(Ease.OutBack).SetUpdate(UpdateType.Normal, true);
        }).Insert(1.1f,
                  topBG.transform.DOLocalMove(topBGPos, 0.3f).SetEase(Ease.InExpo)
                  ).Insert(1.1f,
                           bottomBG.transform.DOLocalMove(bottomBGPos, 0.3f).SetEase(Ease.InExpo)
                           ).Insert(1.3f,
                                    image.transform.DOLocalMove(imagePos, 0.3f).SetEase(Ease.InExpo)
                                    ).Insert(1.3f,
                                             text.transform.DOLocalMove(textPos, 0.3f).SetEase(Ease.InExpo)
                                             ).Insert(2.1f,
                                                      mac.transform.DOLocalMoveY(hostFigure.transform.localPosition.y, 0.3f).SetEase(Ease.InExpo).OnComplete(() => {
            Camera.main.DOShakePosition(0.5f, Vector3.down).SetUpdate(UpdateType.Normal, true);
            hostFigure.SetHostType(HostFigureType.TrumpMAC);
            DarkTonic.MasterAudio.MasterAudio.PlaySound("arrive");
            smokePS.gameObject.SetActive(true);
            Destroy(mac.gameObject);
            Destroy(smokePS.gameObject, 1);
        })
                                                      ).Insert(2.2f,
                                                               Camera.main.DOOrthoSize(10, 0.4f).SetUpdate(UpdateType.Normal, true).SetEase(Ease.OutBack)
                                                               ).InsertCallback(3.8f, () => {
            topBG.transform.DOLocalMove(topBGHiddenPos, 0.5f).SetUpdate(UpdateType.Normal, true);
            bottomBG.transform.DOLocalMove(bottomBGHiddenPos, 0.4f).SetUpdate(UpdateType.Normal, true);
            image.transform.DOLocalMove(imageHiddenPos, 0.5f).SetUpdate(UpdateType.Normal, true);
            text.transform.DOLocalMove(textHiddenPos, 0.4f).SetUpdate(UpdateType.Normal, true);
        }).Insert(4.3f,
                  Camera.main.transform.DOLocalMove(cameraPos, 1f).SetUpdate(UpdateType.Normal, true)
                  ).InsertCallback(5.3f, () => {
            DOTween.To(value => Time.timeScale = value, 0, 1, 0.3f).SetEase(Ease.InCubic).SetUpdate(UpdateType.Normal, true);
            GameManager.Instance.scoreText.gameObject.SetActive(true);
            GameManager.Instance.targetPointer.gameObject.SetActive(true);
            if (callback != null)
            {
                ;
            }
            callback();

            Destroy(gameObject);
        }).SetUpdate(UpdateType.Normal, true);
    }
Ejemplo n.º 9
0
 public void Move()
 {
     HostFigure?.Move(Coordinate, Figures);
     // Console.WriteLine("Поток в котором двигается " + Thread.CurrentThread.Name); //show this
 }