예제 #1
0
 //make sure that falloff works
 public override void useSpell(BallBehavior obj)
 {
     foreach (Collider c in Physics.OverlapSphere(obj.transform.position, 2.0f)) {
         if (c.GetComponent<Rigidbody>() != null) {
             //calculate direction from position to collider
             Vector3 directionTowards = c.transform.position - obj.transform.position;
             power = power - 2 * (directionTowards.magnitude);
             c.GetComponent<Rigidbody>().AddForce(directionTowards.normalized * power, ForceMode.Impulse); //normalized is expensive
         }
     }
 }
    public void InstantShootAttack()
    {
        if ((Time.time - _lastShootTime) >= (shootBufferTime * 2f) && !_isDead)
        {
            BallBehavior bb = SpawnManager.Instance.GetPooledBall();
            bb.transform.position = Vector3.up + transform.position + (transform.forward * 1.5f);
            bb.transform.rotation = transform.rotation;
            bb.Init(shootMinVelocity, "PlayerBall");

            _lastShootTime = Time.time;
        }
    }
    public void InstantShootAttack(float x, float z)
    {
        if ((Time.time - _lastShootTime) >= (shootBufferTime * 2f) && (x != 0f || z != 0f) && !_isDead)
        {
            BallBehavior bb = SpawnManager.Instance.GetPooledBall();
            bb.transform.position = Vector3.up + transform.position + (new Vector3(x, 0f, z) * 1.5f);
            bb.transform.rotation = Quaternion.Euler(0f, Mathf.Atan2(x, z) * Mathf.Rad2Deg, 0f);
            bb.Init(shootMinVelocity, "PlayerBall");

            _lastShootTime = Time.time;
        }
    }
예제 #4
0
 public override void OnTriggerEnter2D(Collider2D collider)
 {
     base.OnTriggerEnter2D(collider);
     if (collider.tag == "Ball")
     {
         BallBehavior bb = collider.GetComponent <BallBehavior>();
         bb.StartCoroutine(bb.SpeedModBuff(Duration, SpeedMod, true));
         GetComponent <CircleCollider2D>().enabled = false;
         anim.Play(Anim);
         //Destroy(gameObject);
     }
 }
예제 #5
0
    void Start()
    {
        rigidbody          = GetComponent <Rigidbody2D>();
        rigidbody.velocity = Vector2.zero;
        ballBehavior       = BallBehaviorFactory.Get(ballType, this);

        if (isAsymptomatic && isOriginalVirus)
        {
            StartCoroutine((ballBehavior as VirusBallBehavior)
                           .TurnsIntoNormalLooking());
        }
    }
예제 #6
0
    private void StartGame()
    {
        GameObject gameObject = GameObject.FindGameObjectWithTag("Ball");

        if (gameObject != null)
        {
            ball = gameObject.GetComponent <BallBehavior>();

            ball.LaunchBall(arrow.GetComponent <ArrowBehavior>().differenceX, arrow.GetComponent <ArrowBehavior>().differenceY, arrow.GetComponent <RectTransform>().localRotation.eulerAngles.z);
            game.onGoing = true;
            arrow.GetComponentInChildren <Image>().enabled = false;
        }
    }
예제 #7
0
    void OnCollisionEnter(Collision other)
    {
        GameObject.Find("PowerDownSound").GetComponent <AudioSource>().Play();

        Destroy(this.gameObject);

        GameObject   ball       = other.gameObject as GameObject;
        BallBehavior ballScript = ball.GetComponent <BallBehavior>();

        ballScript.speed.x *= 1.5f;
        ballScript.speed.y *= 1.5f;
        ballScript.speed.z *= 1.5f;
    }
예제 #8
0
    public void FinalizeShootAttack()
    {
        if (_isShooting && !_isDead)
        {
            BallBehavior bb = SpawnManager.Instance.GetPooledBall();
            bb.transform.position = Vector3.up + transform.position + (transform.forward * 1.5f);
            bb.transform.rotation = transform.rotation;
            bb.Init(_shootChargeVelocity, "PlayerBall");

            _shootFeedback.lineProgress = _shootFeedback.lineOrientation = _shootChargeTimer = _shootChargeVelocity = 0f;
            _lastShootTime = Time.time;
            _isShooting    = false;
        }
    }
예제 #9
0
 /**
  * Static constructor.
  */
 public static void InitGeneralUtils()
 {
     BallUtils.InitBallUtilities();
     NetUtils.InitNetUtils();
     m_mainScript            = GameObject.Find("ScriptHub").GetComponent <Main>();
     m_agentScript           = GameObject.Find("Agent").GetComponent <AgentInput>();
     m_humanScript           = GameObject.Find("P1").GetComponent <HumanInput>();
     m_sessionScript         = GameObject.Find("ScriptHub").GetComponent <SessionBehavior>();
     m_menuScript            = GameObject.Find("ScriptHub").GetComponent <MenuBehavior>();
     m_ballScript            = GameObject.Find("Ball").GetComponent <BallBehavior>();
     m_dataScript            = GameObject.Find("ScriptHub").GetComponent <DataManger>();
     ROLE_SERVER             = 0;
     ROLE_CLIENT             = 1;
     HUMAN_ID                = 0;
     HUMAN_LEFT              = 2;
     HUMAN_RIGHT             = 3;
     AGENT_ID                = 1;
     AGENT_SKILL_RANDOM      = 0;
     AGENT_SKILL_NORMAL      = 1;
     AGENT_SKILL_FAST        = 2;
     RALLY_ID                = 2;
     UNASSIGNED              = 10;
     INPUT_KEYBOARD          = 0;
     INPUT_MOUSE             = 1;
     INPUT_HYDRA             = 2;
     BALL_RADIUS_LARGE       = 2;
     BALL_RADIUS_MEDIUM      = 1;
     BALL_RADIUS_SMALL       = 0.5F;
     PADDLE_SIZE_LARGE       = 9.0757605F;   //150%
     PADDLE_SIZE_MEDIUM      = 6.050507F;    //100%
     PADDLE_SIZE_SMALL       = 4.53788025F;  //75%
     PADDLE_WIDTH_MEDIUM     = 7.41716F;
     RASyN_IP                = "127.0.0.1";
     RASyN_PORT_MAP          = new Dictionary <string, int> ();
     PONG_SERVER_ID          = "PongServer";
     PONG_CLIENT1_ID         = "PongClient1";
     PONG_CLIENT2_ID         = "PongClient2";
     ASSIGNED_PONG_CLIENT_ID = "NULL";
     RASyN_PORT_MAP.Add(PONG_SERVER_ID, 19000);
     RASyN_PORT_MAP.Add(PONG_CLIENT1_ID, 19011);
     RASyN_PORT_MAP.Add(PONG_CLIENT2_ID, 19012);
     jss = new JsonSerializerSettings();
     jss.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
     jss.MissingMemberHandling = MissingMemberHandling.Ignore;
     //jss.PreserveReferencesHandling = PreserveReferencesHandling.Objects;
     DRAW_TIMEOUT = 1000 * 60;         //60 second timeout in milliseconds
     BallUtils.InitBallUtilities();
     NetUtils.InitNetUtils();
     rallyCfg = new RallyConfiguration(Application.dataPath + "/Config/RallyConfiguration.json");
 }
예제 #10
0
 private void updateScore(BallBehavior ballDropped)
 {
     if (!ballDropped.IsWhite())
     {
         //points++;
         points += COLOURED_BALL_PTS;
     }
     else
     {
         //points--;
         points += WHITE_BALL_PTS;
         ballDropped.Reset();
     }
 }
예제 #11
0
    private void OnCollisionEnter(Collision collider)
    {
        BallBehavior script = collider.collider.GetComponent <BallBehavior>();

        if (script != null)
        {
            if (script.team != -1 && script.team != this.team)
            {
                scoreManager.UpdateScore(script.team, 1);
                script.Reset();
                scoreManager.UpdateHealth(this, -1);
                scoreManager.TempFreeze();
            }
        }
    }
    public void ShootAttack()
    {
        if ((Time.time - _lastShootTime) >= shootBufferTime)
        {
            BallBehavior bb = SpawnManager.Instance.GetPooledBall();

            Vector3 forward = (playerTransform.position - transform.position).normalized;

            bb.transform.position = Vector3.up + transform.position + (forward * 1.5f);
            bb.transform.rotation = Quaternion.Euler(0f, Mathf.Atan2(forward.x, forward.z) * Mathf.Rad2Deg, 0f);
            bb.Init(shootVelocity, "EnemyBall");

            _lastShootTime = Time.time;
        }
    }
예제 #13
0
    private void OnTriggerExit(Collider other)
    {
        GameObject   ballGameObj = other.gameObject;
        BallBehavior ballDropped = ballGameObj.GetComponent <BallBehavior>();

        if (ballDropped)
        {
            updateScore(ballDropped);
        }

        if (!ballDropped.IsWhite())
        {
            Destroy(ballGameObj);
        }
    }
예제 #14
0
 private void JoinBalls(BallBehavior otherBall)
 {
     if (MassOfBall > _maxMass)
     {
         int numberOfBalls = (int)(MassOfBall / _startMass);
         Manager.Instance.SplitBall(this.transform.position, numberOfBalls);
         DeactivateBall(this);
     }
     else
     {
         float newMass     = this.MassOfBall + otherBall.MassOfBall;
         float newRadius   = Mathf.Sqrt(Mathf.Pow(this.RadiusOfBall, 2) + Mathf.Pow(otherBall.RadiusOfBall, 2));
         bool  isMassEqual = this.MassOfBall == otherBall.MassOfBall;
         UpdateBall(newMass, newRadius, true, isMassEqual);
     }
 }
예제 #15
0
 private void Update()
 {
     switch (_currentState)
     {
     case AssistState.AutoFire:
         if (Time.time - _lastAutoFireTime > autoFireTime)
         {
             BallBehavior bb = SpawnManager.Instance.GetPooledBall();
             bb.transform.position = Vector3.up + transform.position + (-transform.forward * 1.25f);
             bb.transform.rotation = Quaternion.Euler(transform.eulerAngles + new Vector3(0f, 180f, 0f));
             bb.Init(autoFireVelocity, "PlayerBall", true);
             _lastAutoFireTime = Time.time;
         }
         break;
     }
 }
예제 #16
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "PlayerBall" && (_currentState == AssistState.MultiplyFire || _currentState == AssistState.MultiplyVelocity))
        {
            BallBehavior bb             = other.gameObject.GetComponent <BallBehavior>();
            bool         createByAssist = bb.GetCreateByAssist();
            float        velocity       = bb.GetVelocity();

            switch (_currentState)
            {
            case AssistState.MultiplyFire:
                if (!createByAssist)
                {
                    other.gameObject.SetActive(false);

                    BallBehavior bb1 = SpawnManager.Instance.GetPooledBall();
                    bb1.transform.position = Vector3.up + transform.position + (-transform.right * 1.25f);
                    bb1.transform.rotation = Quaternion.Euler(transform.eulerAngles + new Vector3(0f, -90f, 0f));
                    bb1.Init(velocity, "PlayerBall", true);

                    BallBehavior bb2 = SpawnManager.Instance.GetPooledBall();
                    bb2.transform.position = Vector3.up + transform.position + (-transform.forward * 1.25f);
                    bb2.transform.rotation = Quaternion.Euler(transform.eulerAngles + new Vector3(0f, 180f, 0f));
                    bb2.Init(velocity, "PlayerBall", true);

                    BallBehavior bb3 = SpawnManager.Instance.GetPooledBall();
                    bb3.transform.position = Vector3.up + transform.position + (transform.right * 1.25f);
                    bb3.transform.rotation = Quaternion.Euler(transform.eulerAngles + new Vector3(0f, 90f, 0f));
                    bb3.Init(velocity, "PlayerBall", true);
                }
                break;

            case AssistState.MultiplyVelocity:
                bb.SetVelocity(2f);
                break;
            }
        }
        else if (other.gameObject.tag == "EnemyBall" && (_currentState == AssistState.Shield))
        {
            switch (_currentState)
            {
            case AssistState.Shield:
                other.gameObject.SetActive(false);
                break;
            }
        }
    }
예제 #17
0
    public void Update()
    {
        if (_isInTransition)
        {
            if (Time.time - _transitionStartTime > transitionDuration)
            {
                _isInPosition = !_isInPosition;

                if (_isInPosition)
                {
                    transform.position = _endTransitionTr.position;
                    transform.rotation = _endTransitionTr.rotation;

                    shield.SetActive(_currentState == AltAssistBehavior.AssistState.Shield);
                    autoFire.SetActive(_currentState == AltAssistBehavior.AssistState.AutoFire);
                    multiplyFire.SetActive(_currentState == AltAssistBehavior.AssistState.MultiplyFire);
                }
                else
                {
                    transform.parent        = playerToAttach.headPosition;
                    transform.localPosition = Vector3.zero;
                    transform.localRotation = Quaternion.identity;
                }

                _isInTransition = false;
            }
            else
            {
                float progress = (Time.time - _transitionStartTime) / transitionDuration;
                transform.position = Vector3.Lerp(_startTransitionTr.position, _endTransitionTr.position, progress);
                transform.rotation = Quaternion.Lerp(_startTransitionTr.rotation, _endTransitionTr.rotation, progress);
            }
        }

        if (_isInPosition && _currentState == AltAssistBehavior.AssistState.AutoFire && !_isInTransition)
        {
            if (Time.time - _lastAutoFireTime > autoFireTime)
            {
                BallBehavior bb = SpawnManager.Instance.GetPooledBall();
                bb.transform.position = Vector3.up + transform.position + (-transform.forward * 1.25f);
                bb.transform.rotation = Quaternion.Euler(transform.eulerAngles + new Vector3(0f, 180f, 0f));
                bb.Init(autoFireVelocity, "PlayerBall", true);
                _lastAutoFireTime = Time.time;
            }
        }
    }
예제 #18
0
        public IEnumerator MultipleFrameCollisionTest()
        {
            yield return(new WaitForSeconds(0.1f));

            GameObject   ballObj = new GameObject();
            BallBehavior ball    = ballObj.AddComponent <BallBehavior>();

            ballObj.transform.position = new Vector3(0f, -0.5f, 0f);

            GameObject    colliderRightObj = new GameObject();
            BoxCollider2D colliderRight    = colliderRightObj.AddComponent <BoxCollider2D>();

            colliderRight.tag = "Arena";
            colliderRightObj.transform.position = Vector3.right;

            GameObject    colliderLeftObj = new GameObject();
            BoxCollider2D colliderLeft    = colliderLeftObj.AddComponent <BoxCollider2D>();

            colliderLeft.tag = "Arena";
            colliderLeftObj.transform.position = Vector3.left;

            GameObject    colliderUpObj = new GameObject();
            BoxCollider2D colliderUp    = colliderUpObj.AddComponent <BoxCollider2D>();

            colliderUp.tag = "Arena";
            colliderUpObj.transform.position = Vector3.up;

            objReferences.Add(ballObj);
            objReferences.Add(colliderRightObj);
            objReferences.Add(colliderLeftObj);
            objReferences.Add(colliderUpObj);

            yield return(new WaitForSeconds(0.1f));

            ballObj.SetActive(true);
            ball.Velocity  = 1000f;
            ball.Direction = (Vector3.right + Vector3.up).normalized;

            yield return(new WaitForSeconds(0.1f));

            Assert.Less(1000f, ball.Velocity);
            Assert.AreEqual(3, ball.collisionCounter);
            Assert.AreEqual((Vector3.right + Vector3.down).normalized, ball.Direction);
            Assert.Less(0f, ball.transform.position.x);
            Assert.Greater(0f, ball.transform.position.y);
        }
예제 #19
0
    private IEnumerator AfterBallMovedToNewPosition(Queue <GameObject> stepImages, BallBehavior oldBall, Point start, Point end)
    {
        var oldScore = Score;

        oldBall.StopJumping();
        while (stepImages.Count > 0)
        {
            var stepToRemove = stepImages.Dequeue();
            Destroy(stepToRemove);
            if (stepImages.Count > 0)
            {
                yield return(new WaitForSeconds(0.05f));
            }
        }
        GameBoardManager.Instance.field[end.X, end.Y]     = GameBoardManager.Instance.field[start.X, start.Y];
        GameBoardManager.Instance.field[start.X, start.Y] = null;
        var deletedCount = RemoveCompletedLinesAndAddScore();

        if (deletedCount > 0)
        {
            yield return(new WaitForSeconds(0.10f));
        }
        else
        {
            for (int i = 0; i < 3; i++)
            {
                CreateBallInRandomPlace(NextBalls[i]);
            }
            InitNextBalls();
            RemoveCompletedLinesAndAddScore();
        }
        GameState = GameState.Gameplay;
        CheckGameover();
        if (GameState == GameState.Gameplay &&
            Score > EnemyScore &&
            oldScore <= EnemyScore)
        {
            GameState = GameState.Animation;
            AudioManager.Instance.PlayWinMusicIfCan(() =>
            {
                GameState = GameState.Gameplay;
            });
        }
    }
예제 #20
0
    void OnMouseDown()
    {
        if (GameState != GameState.Gameplay)
        {
            return;
        }
        Vector3 mousePos   = Camera.main.ScreenToWorldPoint(Input.mousePosition);
        Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y);

        var          oldBall         = currentBall;
        var          oldBallPosition = currentBallPosition;
        RaycastHit2D hit             = Physics2D.Raycast(mousePos2D, Vector2.zero);

        if (hit.collider != null)
        {
            var position = hit.collider.gameObject.transform.position;
            currentBallPosition = GameBoardManager.Instance.ScreenCoordToBoardCoords(position);

            currentBall = GameBoardManager.Instance.field[currentBallPosition.X, currentBallPosition.Y];

            if (currentBall != null)
            {
                currentBall.StartJumping();
            }

            if (currentBall != null &&
                oldBall != null &&
                oldBall != currentBall)
            {
                oldBall.StopJumping();
            }

            if (currentBall == null && oldBall != null)
            {
                var successMoveToNewPostion = MoveBallToNewPositionIfCan(oldBall, oldBallPosition, currentBallPosition);
                if (!successMoveToNewPostion)
                {
                    currentBall         = oldBall;
                    currentBallPosition = oldBallPosition;
                }
            }
        }
    }
    private void StartObjectPooling()
    {
        _pooledBalls = new List <BallBehavior>();
        for (int i = 0; i < ballAmount; i++)
        {
            BallBehavior b = Instantiate <BallBehavior>(ballPrefab, transform);
            b.gameObject.SetActive(false);
            _pooledBalls.Add(b);
        }

        _pooledEnemys = new List <EnemyBehavior>();
        for (int i = 0; i < enemyAmount; i++)
        {
            EnemyBehavior e = Instantiate <EnemyBehavior>(enemyPrefab, transform);
            e.Init(player.gameObject);
            e.gameObject.SetActive(false);
            _pooledEnemys.Add(e);
        }
    }
예제 #22
0
    // Use this for initialization
    void Start()
    {
        score           = BallBehavior.getScore();
        FinalScore.text = score.ToString();
        RestartButton.onClick.AddListener(Restart);

        SetHighscore(score);
        setCoins(BallBehavior.getCoins());
        checkScore(score);
        gameNum++;
        if (score == 99)
        {
            ShopSprite.setActiveSprite(0);
        }
        if (gameNum == 10)
        {
            Advertisement.Show();
            gameNum = 0;
        }
    }
        // Update is called once per frame
        void Update()
        {
            // Do we have to approach the target?
            //TODO
            BallBehavior ball = Destination.GetComponent <BallBehavior>();

            //StopThreshold = ball.velocitat - Mathf.Abs((ball.velocitat * ball.velocitat) * ball.amplitud * Mathf.Sin(ball.velocitat * Time.time));

            target = (Vec3)Destination.position;

            if (ErrorFunction(target, Solution) > StopThreshold)
            {
                ApproachTarget(target);
            }

            if (DebugDraw)
            {
                Debug.DrawLine(Effector.transform.position, (Vector3)target, Color.green);
                Debug.DrawLine(Destination.transform.position, (Vector3)target, new Color(0, 0.5f, 0));
            }
        }
    public void ShootBall(Vector3 velocity)
    {
        GetComponent <AudioSource>().Play();

        // You may want to use a random nice color so there is one!
        Color   color   = Random.ColorHSV(0f, 1f, 0.5f, 1f, 0.5f, 1f, 1f, 1f);
        Vector3 color_v = new Vector3(color.r, color.g, color.b);

        // TODO-2.c PhotonNetwork.Instantiate to shoot a ball!
        // You may want to initialize a RPC function call to RPCInitialize()
        //   (See BallBehavior.cs) to set the velocity and color
        //   of the ball across all clients (PhotonTargets.All) and transfer
        //   the ownership of the ball to PC so the ball is correctly destroyed
        //   upon hitting a wall.

        GameObject   ball           = PhotonNetwork.Instantiate("ball", ARCamera.transform.position, Quaternion.identity, 0);
        BallBehavior behavior       = ball.GetComponent <BallBehavior>();
        PhotonView   ballPhotonView = ball.GetComponent <PhotonView>();

        ballPhotonView.RPC("RPCInitialize", PhotonTargets.All, velocity, color_v);
    }
예제 #25
0
    public void PrepareNewLevel(int level)
    {
        BallBehavior ball = GameObject.FindGameObjectWithTag("Ball").GetComponent <BallBehavior>();

        ball.DissolveBall();
        currentLevel = level;

        float  multiplier = float.Parse(stageValues[currentLevel][1]);
        string stage      = stageValues[currentLevel][0];

        if (currentStage != stage)
        {
            isIncreasing = true;
            StartCoroutine(IncreaseStageSize(multiplier));
            currentStage = stage;
            scoreManager.SetStageName(stage);
        }
        else
        {
            InitiateLevel();
        }
    }
예제 #26
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Ball")
        {
            BoredCount = 0;
            BallBehavior ball = collision.gameObject.GetComponent <BallBehavior>();
            collision.gameObject.GetComponent <SpriteRenderer>().color = color;
            if (ball.lastPlayer != null)
            {
                ball.lastPlayer.GetComponent <PlatformBehavior>().playerCard.GetComponent <PlayerCardBehavior>().BallCountUpdate(-1);
            }
            playerCard.GetComponent <PlayerCardBehavior>().BallCountUpdate(1);
            ball.lastPlayer = gameObject;

            Vector2 diff = new Vector2(Horizontal ? collision.transform.position.x - transform.position.x : 0, Horizontal ? 0 : collision.transform.position.y - transform.position.y);
            diff *= DI;

            Rigidbody2D rbo = collision.gameObject.GetComponent <Rigidbody2D>();

            rbo.velocity = (new Vector2(rbo.velocity.x + diff.x, rbo.velocity.y + diff.y)).normalized * rbo.velocity.magnitude;
        }
    }
    public BallBehavior GetPooledBall()
    {
        for (int i = 0; i < _pooledBalls.Count; i++)
        {
            if (!_pooledBalls[i].gameObject.activeInHierarchy)
            {
                return(_pooledBalls[i]);
            }
        }

        //Pool List Shoud Expand
        if (ballShouldExpand)
        {
            BallBehavior b = Instantiate <BallBehavior>(ballPrefab, transform);
            b.gameObject.SetActive(false);
            _pooledBalls.Add(b);
            return(b);
        }
        else
        {
            return(null);
        }
    }
예제 #28
0
        public IEnumerator HighSpeedCollisionTest()
        {
            yield return(new WaitForSeconds(0.1f));

            GameObject   ballObj = new GameObject();
            BallBehavior ball    = ballObj.AddComponent <BallBehavior>();

            ballObj.transform.position = Vector3.zero;

            GameObject    colliderRightObj = new GameObject();
            BoxCollider2D colliderRight    = colliderRightObj.AddComponent <BoxCollider2D>();

            colliderRight.tag = "Arena";
            colliderRightObj.transform.position = Vector3.right * 100;

            GameObject    colliderLeftObj = new GameObject();
            BoxCollider2D colliderLeft    = colliderLeftObj.AddComponent <BoxCollider2D>();

            colliderLeft.tag = "Arena";
            colliderLeftObj.transform.position = Vector3.left * 100;

            objReferences.Add(ballObj);
            objReferences.Add(colliderRightObj);
            objReferences.Add(colliderLeftObj);

            yield return(new WaitForSeconds(0.1f));

            ballObj.SetActive(true);
            ball.Velocity = 1000f;

            yield return(new WaitForSeconds(5));

            Assert.Less(1000f, ball.Velocity);
            Assert.Less(10, ball.collisionCounter);
            Assert.Greater(colliderRightObj.transform.position.x, ball.transform.position.x);
            Assert.Less(colliderLeftObj.transform.position.x, ball.transform.position.x);
        }
예제 #29
0
 //what will happen when spell is cast
 public override void useSpell(BallBehavior obj)
 {
     obj.GetComponent<Rigidbody>().AddForce(new Vector3(0, 5f, 0), ForceMode.Impulse);
 }
예제 #30
0
 //defines the conditions that have to be met for a spell to be used
 public override bool isUsable(BallBehavior obj)
 {
     return obj.isGrounded();
 }
예제 #31
0
 public override void useSpell(BallBehavior obj)
 {
     throw new NotImplementedException();
 }
예제 #32
0
 public override bool isUsable(BallBehavior obj)
 {
     return true;
 }
예제 #33
0
 void Start()
 {
     ball = GetComponent <BallBehavior>();
 }
예제 #34
0
	public void InitBallEvents (BallBehavior ball)
	{
		ball.BallThrown += OnBallThrown;
		ball.BallDestroyed += OnBallDestroyed;
	}
예제 #35
0
 //what will happen when the spell is cast
 public abstract void useSpell(BallBehavior obj);
예제 #36
0
 //what defines the spell as being able to be cast
 public abstract bool isUsable(BallBehavior obj);
 void Start()
 {
     bb = GameObject.Find("Main Camera").GetComponentInChildren<BallBehavior>();
 }
예제 #38
0
    private bool MoveBallToNewPositionIfCan(BallBehavior oldBall, Point start, Point end)
    {
        for (int x = 0; x < 9; x++)
        {
            for (int y = 0; y < 9; y++)
            {
                mapForPathFinding[x, y] = GameBoardManager.Instance.field[x, y] == null ? 0 : 1;
            }
        }

        mapForPathFinding[start.X, start.Y] = 0;
        var resultPath = pathSearcher.Search(mapForPathFinding, start, end);

        if (resultPath.Any())
        {
            var oldPosition = GameBoardManager.Instance.GetPos(start.X, start.Y);
            Queue <GameObject> stepImages = new Queue <GameObject>();

            if (ShowPath)
            {
                var firstStepImage = GetNextImage(new Vector3Combined
                {
                    Start = oldPosition,
                    End   = GameBoardManager.Instance.GetPos(resultPath[0].X, resultPath[0].Y)
                });
                stepImages.Enqueue(firstStepImage);
                GameState = GameState.Animation;

                oldBall.MoveByPath(resultPath.Select(pathStep => GameBoardManager.Instance.GetPos(pathStep.X, pathStep.Y)).ToArray(),
                                   () =>
                {
                    StartCoroutine(AfterBallMovedToNewPosition(stepImages, oldBall, start, end));
                },
                                   (movedPosition) =>
                {
                    GameObject stepImage = GetNextImage(movedPosition);

                    if (stepImage != null)
                    {
                        stepImages.Enqueue(stepImage);
                    }
                });
            }
            else
            {
                GameState = GameState.Animation;
                oldBall.StartTeleport(() =>
                {
                    oldBall.transform.position = GameBoardManager.Instance.GetPos(end.X, end.Y);

                    oldBall.StartShowingAnimation(() =>
                    {
                        StartCoroutine(AfterBallMovedToNewPosition(stepImages, oldBall, start, end));
                    });
                });
            }
            return(true);
        }
        else
        {
            AudioManager.Instance.PlaySound(wrongPlace);
            return(false);
        }
    }
예제 #39
0
    void randomExpansionSelection()
    {
        _timer += GameTime.Instance.DeltaTime;
        if (_timer >= _time)
        {
          _timer = 0f;
          _time = Random.Range(_timeRange.x, _timeRange.y);
          _expansionRadius = 0f;

          Color c = _colors[_currentColor];
          _currentColor++;
          if (_currentColor == _colors.Length) _currentColor = 0;
          int number = 0;
          do
          {
        int random = Random.Range(0, _balls.Length);
        _current = _balls[random];
        number++;
          } while (_current.color != c && number < 100);
        }
    }
 /// <summary>
 /// Initializes members.
 /// </summary>
 public override void InitializeAgent()
 {
     _academy       = GameObject.FindGameObjectWithTag("Academy").GetComponent <BallLabyrinthAcademy>();
     _ballRigidbody = _ball.GetComponent <Rigidbody>();
     _ballBehavior  = _ball.GetComponent <BallBehavior>();
 }
 // Use this for initialization
 void Start()
 {
     AudioController(0.1f);
     apelidoUsuario.text = Sessao.apelido;
     placar.SetActive(false);
     bb = cameraJogo.GetComponentInChildren<BallBehavior>();
     alvoTempoBehavior = alvoTempo.GetComponent<AlvoTempoBehavior>();
     alvoTempo.SetActive(false);
     ResetGame();
     carregando.SetActive(false);
 }
 // Use this for initialization
 void Start()
 {
     gameController = GameObject.Find("!GameController").GetComponent<GameSceneController>();
     bb = GameObject.Find("Main Camera").GetComponentInChildren<BallBehavior>();
     audioController = GameObject.Find("AudioController");
 }