Exemple #1
0
 public Ball()
 {
     body = new BaseBall();
     //挂载
     this.DataContext = body;
     Width            = 2 * Constant.Ball_Radius;
 }
Exemple #2
0
    protected override void OnTriggerEnter(Collider other)
    {
        BaseBall otherBall = other.GetComponentInParent <BaseBall>();

        if (otherBall.useHealth && otherBall.infected)
        {
            base.OnTriggerEnter(other);
            return;
        }

        if (otherBall.isMedic)
        {
            return;
        }

        if (otherBall.infected || otherBall.isScaling)
        {
            float healChance = m_cachedVirusLevel / (m_cachedVirusLevel + otherBall.m_cachedVirusLevel);

            if (Random.value < healChance)
            {
                otherBall.SetHealed();
            }
            else
            {
                Debug.Log("KILL");
                OnDeath();
            }
        }
    }
        public BaseBall built(int val)
        {
            BaseBall ball = new BaseBall(color,Vector2.Zero,0,texture,val);
            ball.setColor(color);
            switch(impactType){
                case "SubImpact":
                    ball.setImpact(new SubImpact(ball));
                    break;
                default:
                    ball.setImpact(new ImpactInterface(ball));
                    break;

            }

            switch(roadType){

                case "Rush":
                    ball.setRoad(new Rush(ball));
                    break;

                case "RandomRoad":
                    ball.setRoad(new RandomRoad(ball));
                    break;

                case "LinerRoad":
                    ball.setRoad(new LinerRoad(ball));
                    break;

                default:
                    ball.setRoad(new RandomRoad(ball));
                    break;
            }

            return ball;
        }
Exemple #4
0
    //float t=0;
    //private void ShootTimer(float degree)
    //{
    //    t += Time.deltaTime;
    //    if (t >= shootSpeed)
    //    {
    //        t = 0;
    //        Shoot(degree);
    //    }
    //}

    private void Shoot()
    {
        float    d        = degree;
        BaseBall baseBall = GameManager.I().GetBaseBall();//공 가지고 오기


        if (baseBall == null)
        {
            return;                  //공을 더 이상 발사할 수 없으면 그만
        }
        anim.SetTrigger("Shoot");


        d -= 90;            //계산을 편하게 하기 위해 더해두었던 90도 다시 빼기
        d *= Mathf.Deg2Rad; //라디안 값으로 변환

        //계산 후 노말라이즈
        Vector2 vector = new Vector2(Mathf.Cos(d), Mathf.Sin(d));

        vector = vector.normalized;

        baseBall.Init(ShootPoint.position, -vector, ballSpeed, ballTime, ballReflecTime); //위치,방향,속도,반사 횟수 초기화

        GameManager.I().PlaySound(GameManager.I().sound_Ball_Shoot);                      //발사 소리
    }
Exemple #5
0
        static void Main(string[] args)
        {
            BaseBall bb = new BaseBall();

            Console.WriteLine(bb);
            Console.ReadKey();
        }
Exemple #6
0
 public void RegisterBall(BaseBall ball)
 {
     if (activeBalls == null)
     {
         activeBalls = new List <BaseBall>();
     }
     activeBalls.Add(ball);
 }
Exemple #7
0
    public bool SwingBat(BaseBall ball)
    {
        if (ball.Speed < 90.52)
        {
            return(true);
        }

        return(false);
    }
    public void AddBall()
    {
        GameObject ballObject = (GameObject)Instantiate(ballPrefabs, GetMainBall().transform.position, Quaternion.identity, transform);
        BaseBall   ball       = ballObject.GetComponent <BaseBall>();

        ball.ballManager = this;
        balls.Add(ball);
        ball.OnStart();
    }
 public virtual Boolean impact(BaseBall otherBall)
 {
     if (ball.getVal() < otherBall.getVal())
     {
         otherBall.addVal(ball.getVal() / 10);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #10
0
 public override bool impact(BaseBall otherBall)
 {
     if (ball.getVal() < otherBall.getVal())
     {
         otherBall.addVal(-ball.getVal() / 10);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #11
0
 public virtual Boolean impact(BaseBall otherBall)
 {
     if (ball.getVal() < otherBall.getVal())
     {
         otherBall.addVal(ball.getVal() / 10);
         ScoreBoard.getInstance().addScore(ball.getVal() / 10);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #12
0
        public override bool impact(BaseBall otherBall)
        {
            if (ball.getVal() < otherBall.getVal())
            {
                otherBall.addVal(-ball.getVal() / 10);
                return true;
            }
            else
            {

                return false;
            }
        }
Exemple #13
0
 public override bool impact(BaseBall otherBall)
 {
     if (ball.getVal() < otherBall.getVal())
     {
         otherBall.addVal(-ball.getVal() / 10);
         ScoreBoard.getInstance().addScore(-ball.getVal() / 10);
         return(true);
     }
     else
     {
         return(false);
     }
 }
        public override bool impact(BaseBall otherBall)
        {
            if(player.getVal()<otherBall.getVal()){
                //玩家被大球吃
                player.dead();
            }else if(player.getVal()==otherBall.getVal()){
                //TODO:相等的时候处理,现在这个不太好
                otherBall.addVal(-new Random().Next(otherBall.getVal()/2));
                player.addVal(-new Random().Next(player.getVal() / 2));

            }

            return true;
        }
Exemple #15
0
        public void SetBody(BaseBall ball)
        {
            body = ball;
            //挂载
            this.DataContext = body;

            Image       img = new Image();
            BitmapImage bmp = new BitmapImage();

            bmp.BeginInit();                                                           //初始化
            bmp.UriSource = new Uri(UIConstant.BallsImage[body.ID], UriKind.Relative); //设置图片路径
            bmp.EndInit();                                                             //结束初始化

            Source = bmp;                                                              //设置显示图片
        }
Exemple #16
0
        public override bool impact(BaseBall otherBall)
        {
            if (player.getVal() < otherBall.getVal())
            {
                //玩家被大球吃
                player.dead();
            }
            else if (player.getVal() == otherBall.getVal())
            {
                //TODO:相等的时候处理,现在这个不太好
                otherBall.addVal(-new Random().Next(otherBall.getVal() / 2));
                player.addVal(-new Random().Next(player.getVal() / 2));
            }

            return(true);
        }
    protected override void OnTriggerEnter(Collider other)
    {
        BaseBall otherBall = other.GetComponentInParent <BaseBall>();

        if (otherBall.useHealth && !otherBall.infected)
        {
            otherBall.currentHealth = -1;
            otherBall.SetInfected();

            /*
             * if (otherBall.objectAffectingBall)
             * {
             *  otherBall.objectAffectingBall = null;
             * }*/
            return;
        }
    }
Exemple #18
0
    protected virtual void OnTriggerExit(Collider other)
    {
        BaseBall otherBall = other.GetComponentInParent <BaseBall>();

        if (useHealth)
        {
            if (otherBall == null)
            {
                return;
            }

            if (objectAffectingBall && otherBall.gameObject == objectAffectingBall)
            {
                objectAffectingBall = null;
            }
        }
    }
        public override bool impact(BaseBall otherBall)
        {
            if (player.getVal() <= otherBall.getVal())
            {
                //玩家被大球吃
                if (detaTime <= 0)
                {
                    player.dead();
                }
                else
                {
                    Resourse.getInstance().deadSound.Play();
                    player.addVal(-2);
                    detaTime--;
                }
            }

            return(true);
        }
    public void Init(int count)
    {
        if (balls == null)
        {
            balls = new List <BaseBall>();
        }
        else
        {
            balls.Clear();
        }

        for (int i = 0; i < count; i++)
        {
            GameObject ballObject = (GameObject)Instantiate(ballPrefabs, transform);
            BaseBall   ball       = ballObject.GetComponent <BaseBall>();
            ball.ballManager = this;
            balls.Add(ball);
        }
    }
Exemple #21
0
        public Boolean checkBall(BaseBall ball)
        {
            if (ball is PlayerBall)
            {
                Vector2 oldPo = ball.getPosition();

                if (oldPo.X < 0)
                {
                    oldPo.X = wallRect.Width - ball.getRect().Width;
                }
                if (oldPo.Y < 0)
                {
                    oldPo.Y = 0;
                }
                if (oldPo.X >( wallRect.Width-ball.getRect().Width))
                {
                    oldPo.X = (ball.getRect().Width);
                }
                if (oldPo.Y > (wallRect.Height-ball.getRect().Height))
                {
                    oldPo.Y = (wallRect.Height - ball.getRect().Height);
                }

                ball.setPosition(oldPo);
                return true;
            }
            else
            {

                Vector2 oldPo = ball.getPosition();

                if (oldPo.X < 0 || oldPo.Y < 0 || oldPo.X > wallRect.Width-ball.getRect().Width || oldPo.Y > wallRect.Height-ball.getRect().Height)
                {
                    return false;
                }
                else
                {
                    return true;
                }

            }
        }
Exemple #22
0
    private void placeHeldObject()
    {
        GameObject newObj = Instantiate(heldObject, mouseWorldPos(), Quaternion.identity, ballContainer);

        newObj.SetActive(true);
        stopHolding();

        BaseBall newBall = newObj.GetComponent <BaseBall>();

        if (newBall && !newObj.HasTag(Tag.Cue))
        {
            int player_num = TurnManager.instance.currentPlayerIndex;

            newBall.SetOwner(player_num);

            Player owner = TurnManager.instance.players[player_num];

            owner.BallGained();
        }
    }
Exemple #23
0
    protected virtual void OnTriggerEnter(Collider other)
    {
        if (isScaling)
        {
            return;
        }

        BaseBall otherBall = other.GetComponentInParent <BaseBall>();

        if (infected)
        {
            if (otherBall == null || otherBall.isMedic)
            {
                return;
            }

            if (otherBall.useHealth && !otherBall.infected)
            {
                //otherBall.objectAffectingBall = gameObject;
                return;
            }

            if (!otherBall.infected)
            {
                float infectChance = m_cachedVirusLevel / (m_cachedVirusLevel + otherBall.m_cachedVirusLevel);
                if (Random.value < infectChance)
                {
                    Debug.Log("set Infected");
                    otherBall.SetInfected();
                }
            }
        }
        else if (isMedic)
        {
            if (otherBall.useHealth && otherBall.infected && !otherBall.isSuperinfected)
            {
                otherBall.objectAffectingBall = gameObject;
            }
        }
    }
Exemple #24
0
        public BaseBall built(int val)
        {
            BaseBall ball = new BaseBall(color, Vector2.Zero, 0, texture, val);

            ball.setColor(color);
            switch (impactType)
            {
            case "SubImpact":
                ball.setImpact(new SubImpact(ball));
                break;

            default:
                ball.setImpact(new ImpactInterface(ball));
                break;
            }

            switch (roadType)
            {
            case "Rush":
                ball.setRoad(new Rush(ball));
                break;

            case "RandomRoad":
                ball.setRoad(new RandomRoad(ball));
                break;

            case "LinerRoad":
                ball.setRoad(new LinerRoad(ball));
                break;

            default:
                ball.setRoad(new RandomRoad(ball));
                break;
            }


            return(ball);
        }
Exemple #25
0
 public SubImpact(BaseBall ball)
     : base(ball)
 {
     ball.setColor(Color.Red);
 }
Exemple #26
0
    protected virtual void OnTriggerStay(Collider other)
    {
        BaseBall otherBall = other.GetComponentInParent <BaseBall>();

        if (otherBall == null || !otherBall.useHealth)
        {
            return;
        }



        if (infected)
        {
            if (!otherBall.objectAffectingBall && !otherBall.infected)
            {
                otherBall.objectAffectingBall = gameObject;
            }

            float infectChance = m_cachedVirusLevel / (m_cachedVirusLevel + otherBall.m_cachedVirusLevel);
            float dmg          = infectChance;


            if (!otherBall.infected)
            {
                otherBall.ChangeHealth(-dmg, gameObject);
                //otherBall.currentHealth -= dmg;

                if (otherBall.currentHealth < 0)
                {
                    //Debug.Log("Current Health "+currentHealth);
                    otherBall.SetInfected();
                }
            }
            else
            {
                if (otherBall.currentHealth > -otherBall.startHealth * 0.5f)
                {
                    otherBall.ChangeHealth(-dmg, gameObject);
                    //otherBall.currentHealth -= dmg;
                }
            }
        }
        else if (isMedic)
        {
            if (otherBall.isSuperinfected)
            {
                return;
            }

            if (!otherBall.objectAffectingBall && otherBall.infected)
            {
                otherBall.objectAffectingBall = gameObject;
            }

            float infectChance = m_cachedVirusLevel / (m_cachedVirusLevel + otherBall.m_cachedVirusLevel);
            float heal         = 0.5f;

            if (otherBall.infected)
            {
                otherBall.ChangeHealth(heal, gameObject);
                currentHealth -= heal * 2f; //Damage medics when healing other balls
                //otherBall.currentHealth += heal;

                if (otherBall.currentHealth > otherBall.startHealth * 0.5f)
                {
                    otherBall.SetHealed();
                    //Debug.Log("Current Health Healed "+otherBall.currentHealth);
                }
            }
            else
            {
                if (otherBall.currentHealth < otherBall.startHealth)
                {
                    otherBall.ChangeHealth(heal, gameObject);
                    //Debug.Log("Healing OtherBall");
                    //otherBall.currentHealth += heal;
                }
            }

            if (currentHealth < 0)
            {
                OnDeath();
            }
        }

        if (objectAffectingBall && otherBall.gameObject == objectAffectingBall)
        {
            resetObjectTimer = 1;
        }
    }
Exemple #27
0
 public Rush(BaseBall ball) : base(ball)
 {
 }
Exemple #28
0
 public Rush(BaseBall ball)
     : base(ball)
 {
 }
 public PlayerImpact(BaseBall p)
     : base(p)
 {
     player = (PlayerBall)p;
 }
Exemple #30
0
 public RandomRoad(BaseBall ball)
     : base(ball)
 {
     randomTime = new Random().Next(100);
 }
Exemple #31
0
 public PlayerImpact(BaseBall p) : base(p)
 {
     player = (PlayerBall)p;
 }
Exemple #32
0
 public RandomRoad(BaseBall ball)
     : base(ball)
 {
     randomTime = new Random().Next(100);
 }
 public RoadInterface(BaseBall ball)
 {
     this.ball = ball;
 }
Exemple #34
0
 public void UnregisterBall(BaseBall ball)
 {
     activeBalls.Remove(ball);
 }
Exemple #35
0
 public ImpactInterface(BaseBall ball)
 {
     this.ball = ball;
 }
Exemple #36
0
 public RoadInterface(BaseBall ball)
 {
     this.ball = ball;
 }
Exemple #37
0
 public SubImpact(BaseBall ball) : base(ball)
 {
     ball.setColor(Color.Red);
 }
Exemple #38
0
        private int direction = 1;//

        public LinerRoad(BaseBall ball)
            : base(ball)
        {
        }
Exemple #39
0
        /// <summary>Showing some type of equipments</summary>
        private void ShowEquipmentByType(int eq)
        {
            if (eq < 0 || eq > 2)
            {
                return;
            }

            Console.Clear();
            if (eqCollection.Length == 0)
            {
                Console.WriteLine("The shop is empty!");
                return;
            }

            Console.WriteLine("The list of the concrete type of the equipment:");

            int           countItemsConcreteType = 0;
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < eqCollection.Length; i++)
            {
                switch (eq)
                {
                case 0:
                {
                    BaseBall beq = eqCollection.GetEquipmentByIndex(i) as BaseBall;
                    if (beq != null)
                    {
                        SetEquipmentInfoForType(ref sb, ref countItemsConcreteType, beq.GetInfo());
                    }

                    break;
                }

                case 1:
                {
                    BaseBike beq = eqCollection.GetEquipmentByIndex(i) as BaseBike;
                    if (beq != null)
                    {
                        SetEquipmentInfoForType(ref sb, ref countItemsConcreteType, beq.GetInfo());
                    }

                    break;
                }

                case 2:
                {
                    BaseBoat beq = eqCollection.GetEquipmentByIndex(i) as BaseBoat;
                    if (beq != null)
                    {
                        SetEquipmentInfoForType(ref sb, ref countItemsConcreteType, beq.GetInfo());
                    }

                    break;
                }
                }
            }


            if (countItemsConcreteType == 0)
            {
                Console.WriteLine("The equipments of the concrete type were not found!");
            }
            else
            {
                Console.WriteLine(sb);
            }
        }