public BowlScript Spawn(Bowl body, Transform parent)
        {
            var bowl = Instantiate(this, parent);

            bowl.ID   = body.ID;
            bowl.Body = body;
            body.StoneIDs.ForEach(x =>
            {
                var target = bowl.transform.position;
                target.x  -= body.Position == Position.Score ? 0 : 7.6f;
                target.y  += body.Position == Position.Score ? 6 - 1 : 3;
                target.z  += body.Position == Position.Score ? -0.5f : 0;
                if (!Access.BodyDataExists(x))
                {
                    new StoneBodyData(x, target, Quaternion.identity);
                }
                if (GameResources.IsContinue)
                {
                    GameResources
                    .Stones[Mathf.Abs(x.GetHashCode() % GameResources.Stones.Count)]
                    .Spawn(new StoneBody(x), bowl.transform);
                }
                else
                {
                    GameResources.Queue.SpawnStone(x, body.ID, body.Owner, body.Position);
                }
            });
            return(bowl);
        }
Exemple #2
0
        public void Capture(Bowl scoreBowl)
        {
            var count = StoneIDs.Count;

            scoreBowl.Capture(StoneIDs);
            StoneIDs.Clear();
            Messages.Send(new StonesCaptured(Owner, count));
        }
        public void MoveTo(Bowl bowl)
        {
            var bowlScript = Access.Script <BowlScript>(bowl.ID);

            gameObject.transform.SetParent(bowlScript.transform);
            Body.StoneData.Target = bowlScript.transform.position;
            var position = bowl.Position;
            var x        = position == Position.Score ? 0 : 7.6f;
            var y        = position == Position.Score ? Lift - 1 : Lift;
            var z        = position == Position.Score ? -0.5f : 0;

            Body.StoneData.Target        = new Vector3(Body.StoneData.Target.x - x, Body.StoneData.Target.y + y, Body.StoneData.Target.z + z);
            Body.StoneData.TargetReached = false;
            RigidBody.useGravity         = false;
            Body.StoneData.UseGravityUponTargetReached = true;
        }
Exemple #4
0
 public void PreviewCapture(Bowl scoreBowl)
 {
     scoreBowl.PreviewCapture(PreviewStoneIDs);
     PreviewStoneIDs.Clear();
 }
Exemple #5
0
 public void PreviewScore(Bowl scoreBowl)
 {
     scoreBowl.AddStones(StoneIDs);
     PreviewStoneIDs.Clear();
 }
Exemple #6
0
 public void Score(Bowl scoreBowl)
 {
     scoreBowl.AddStones(StoneIDs);
     StoneIDs.Clear();
 }