Наследование: MonoBehaviour
Пример #1
0
 void Awake()
 {
     m_gameManager = GameObject.Find("GameManager").GetComponent <GameManager>();
     m_uiManager   = GameObject.Find("UIManager").GetComponent <UIManager>();
     m_ball        = GameObject.Find("Ball").GetComponent <BallMover>();
     m_leftPad     = GameObject.Find("LeftPad");
     m_rightPad    = GameObject.Find("RightPad");
 }
Пример #2
0
    private void OnTriggerEnter(Collider other)
    {
        BallMover ball     = other.GetComponent <BallMover>();
        Rigidbody rbd      = ball.rbd;
        Vector3   force    = other.transform.right * ball.rbd.velocity.magnitude * 2;
        Vector3   newForce = Vector3.Lerp(force, new Vector3(0, vel * friction), 0.5f) * 2;

        rbd.velocity += newForce;
    }
Пример #3
0
    public BallMover Shoot(GameObject thrownBall)
    {
        BallMover mover = GameObject.Instantiate(thrownBall).GetComponent <BallMover>();

        mover.ResetPosition(throwPoint.transform.position);
        mover.ThrowBall(answerVelocity * direction, answerAngle * direction, int.Parse(playerNumber.text));
        shotLeft = true;
        return(mover);
    }
Пример #4
0
 // Start is called before the first frame update
 void Start()
 {
     ball               = FindObjectOfType <BallMover>();
     level              = FindObjectOfType <LevelGenerator>();
     state              = State.Standing;
     Lives              = 3;
     platformBounds     = GetComponent <SpriteRenderer>().bounds;
     midPoint           = (level.leftBound.position.x + level.rightBound.position.x) / 2;
     transform.position = new Vector2(midPoint, transform.position.y);
 }
Пример #5
0
    private void OnTriggerEnter(Collider other)
    {
        BallMover ball = other.gameObject.GetComponent <BallMover>();

        if (ball)
        {
            Explode(transform.position);
            Destroy(ball.gameObject);
            audioSource.Play();
            Invoke("NextLevel", delay);
        }
    }
Пример #6
0
    private void OnTriggerEnter(Collider other)
    {
        BallMover ball = other.GetComponent <BallMover>();

        if (ball)
        {
            Rigidbody rbd   = ball.rbd;
            Vector3   force = other.transform.right * ball.rbd.velocity.magnitude * 2;
            force         = ball.rbd.velocity.x > 0 ? -force : force;
            rbd.velocity += force;
        }
    }
Пример #7
0
    public GameManagerZSerializer(string ZUID, string GOZUID) : base(ZUID, GOZUID)
    {
        var instance = ZSerializer.ZSerialize.idMap[ZSerializer.ZSerialize.CurrentGroupID][ZUID];

        highScore    = (System.Int32) typeof(GameManager).GetField("highScore").GetValue(instance);
        currentScore = (System.Int32) typeof(GameManager).GetField("currentScore").GetValue(instance);
        playerName   = (System.String) typeof(GameManager).GetField("playerName").GetValue(instance);
        position     = (UnityEngine.Vector3) typeof(GameManager).GetField("position").GetValue(instance);
        ballMover    = (BallMover)typeof(GameManager).GetField("ballMover").GetValue(instance);
        canvas       = (UnityEngine.GameObject) typeof(GameManager).GetField("canvas").GetValue(instance);
        groupID      = (System.Int32) typeof(ZSerializer.PersistentMonoBehaviour).GetField("groupID", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(instance);
        autoSync     = (System.Boolean) typeof(ZSerializer.PersistentMonoBehaviour).GetField("autoSync", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(instance);
    }
Пример #8
0
    void Awake()
    {
        m_gameManager   = GameObject.Find("GameManager").GetComponent <GameManager>();
        m_gameSequencer = GameObject.Find("GameSequencer").GetComponent <GameSequencer>();

        m_ballTransform = GameObject.Find("Ball").transform;
        m_ballMover     = GameObject.Find("Ball").GetComponent <BallMover>();
        m_ballSfx       = GameObject.Find("Ball").GetComponent <AudioSource>();
        m_sfxHit        = Resources.Load("hitball") as AudioClip;
        m_sfxSmash      = Resources.Load("smashball") as AudioClip;

        m_particles   = GetComponentInChildren <ParticleSystem>();
        m_gfxAnimator = GetComponentInChildren <Animator>();
    }
    void FixedUpdate()
    {
        if (!timerPaused && bothAnswered)
        {
            timePassed += Time.deltaTime * 3;
        }
        else if (!timerPaused)
        {
            timePassed += Time.deltaTime;
        }

        if (bothAnswered)
        {
            timerNumber.text = (timePassed - firstAnswerTime).ToString("0.00");
        }
        else
        {
            timerNumber.text = timePassed.ToString("0.00");
        }

        // If ready, when each player
        if (bothAnswered)
        {
            foreach (Player player in players)
            {
                bool testForAWinner = false;
                foreach (Vector2Int i in ballResults)
                {
                    testForAWinner = testForAWinner || Mathf.Abs(i.y) == 1;
                }

                if (ballResults.Count == 2 || (testForAWinner && ballResults.Count > 0 && ballsInPlay.Count == 0)) // Either both results are ready or one player won before another could even shoot
                {
                    StopGameAndShowResults();
                }

                if (!player.shotLeft && player.answerTime <= timePassed)
                {
                    BallMover ballShot = player.Shoot(ballPrefab);
                    ballsInPlay.Add(ballShot);
                    ballShot.controller = this;
                }
            }
        }
    }
Пример #10
0
 void Start()
 {
     ball  = GameObject.Find("Ball");
     mover = ball.GetComponent <BallMover>();
     sr    = ball.GetComponent <SpriteRenderer>();
 }
        private void Start()
        {
            ballMover = ballMoverFactory.Create(ballFacade);

            LoadGameState();
        }
Пример #12
0
 // Start is called before the first frame update
 void Start()
 {
     parent = gameObject.GetComponentInParent <BallMover>();
 }
 public void BallDestroyed(BallMover destructed, int hitSuccess)
 {
     ballResults.Add(new Vector2Int(destructed.thrower, hitSuccess));
     ballsInPlay.Remove(destructed);
     GameObject.Destroy(destructed.gameObject);
 }
Пример #14
0
    // public override void OnPostLoad()
    // {
    //     ballMover = FindObjectOfType<BallMover>();
    // }

    private void Start()
    {
        ballMover = FindObjectOfType <BallMover>();
        ZSerialize.LoadScene();
    }