Esempio n. 1
0
 static void ColisionDetection(Stones stonePosition)
 {
     if (dworfCurrentPosition.X <= stonePosition.X && stonePosition.X <= dworfCurrentPosition.X + 2 && stonePosition.Y == dworfCurrentPosition.Y)
     {
         lives--;
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Red;
         System.Threading.Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Black;
         System.Threading.Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Red;
         System.Threading.Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Black;
         System.Threading.Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Red;
         System.Threading.Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Black;
         System.Threading.Thread.Sleep(100);
         Console.Clear();
     }
 }
 static void ColisionDetection(Stones stonePosition)
 {
     if (dwarfCurrentPosition.X <= stonePosition.X && stonePosition.X <= dwarfCurrentPosition.X + 2 && stonePosition.Y == dwarfCurrentPosition.Y)
     {
         lives--;
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Red;
         Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Black;
         Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Red;
         Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Black;
         Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Red;
         Thread.Sleep(100);
         Console.Clear();
         Console.BackgroundColor = ConsoleColor.Black;
         Thread.Sleep(100);
         Console.Clear();
     }
 }
Esempio n. 3
0
        internal King GetKing()
        {
            if (Color == EnumStoneColor.Black)
            {
                return((King)Stones.FirstOrDefault(s => s is King));
            }

            return((King)Stones.FirstOrDefault(s => s is King));
        }
Esempio n. 4
0
    static void Main(string[] args)
    {
        var numbers = Console.ReadLine()
                      .Split(", ")
                      .Select(int.Parse);

        Stones <int> stones = new Stones <int>(numbers);

        Console.WriteLine(string.Join(", ", stones));
    }
    private bool isShow;         //提示消息框是否显示

    void Awake()
    {
        GameObject numLabel = GameObject.Find("UI Root/Camera/Anchor-Center/KeySaleNumPanel/NumSprite/Label");

        buyNum = numLabel.gameObject.GetComponent <NumLabel>();
        GameObject key = GameObject.Find("UI Root/Camera/Anchor-TopRight/Panel/Key");

        keyNum = key.gameObject.GetComponent <KeyNum>();
        GameObject stone = GameObject.Find("UI Root/Camera/Anchor-TopRight/Panel/Stones");

        stonesNumber = stone.gameObject.GetComponent <Stones>();
    }
Esempio n. 6
0
        public override int GetHashCode()
        {
            var bricksHash = Bricks.Aggregate(0, (i, details) => i ^ details.GetHashCode());
            var stonesHash = Stones.Aggregate(0, (i, details) => i ^ details.GetHashCode());
            var waterHash  = Water.Aggregate(0, (i, details) => i ^ details.GetHashCode());

            unchecked
            {
                return(((Bricks.Count() * 397) ^ bricksHash) + ((Stones.Count() * 397) ^ stonesHash) +
                       ((Water.Count() * 397) ^ waterHash));
            }
        }
Esempio n. 7
0
        public override string ToString()
        {
            var sbRes = new StringBuilder();

            sbRes.Append($"[{Id}]{Verdict}{{");
            foreach (var c in Indicdentals)
            {
                sbRes.Append($"{c.Id},");
            }
            if (Indicdentals.Count > 0)
            {
                sbRes.Remove(sbRes.Length - 1, 1);
            }
            sbRes.AppendLine("}");
            for (var i = 0; i < Stones.GetLength(0); i++)
            {
                for (var j = 0; j < Stones.GetLength(1); j++)
                {
                    switch (Stones[i, j])
                    {
                    case Stone.Black:
                        sbRes.Append('X');
                        break;

                    case Stone.White:
                        sbRes.Append('O');
                        break;

                    default:
                        sbRes.Append(' ');
                        break;
                    }
                    if (j < Stones.GetLength(0) - 1)
                    {
                        sbRes.Append('|');
                    }
                }
                if (i < Stones.GetLength(0) - 1)
                {
                    sbRes.AppendLine();
                    sbRes.Append('-', Stones.GetLength(1) * 2 - 1);
                    sbRes.AppendLine();
                }
            }
            return(sbRes.ToString());
        }
Esempio n. 8
0
        public bool Equals(InitiationMessage other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            // Refer BroadcastMessage for comments on how Equals method is implemented.
            var bricksEquality = Bricks.Count() == other.Bricks.Count() && Bricks.All(other.Bricks.Contains);
            var stonesEquality = Stones.Count() == other.Stones.Count() && Stones.All(other.Stones.Contains);
            var waterEquality  = Water.Count() == other.Water.Count() && Water.All(other.Water.Contains);

            return(PlayerNumber == other.PlayerNumber && bricksEquality && stonesEquality && waterEquality);
        }
    /* Create instance of StonePrefab on each possition we've made and setup it's image, and id */
    private void CreateStones()
    {
        float startStoneCord = 0f + (StonesCount % 10) / 2;
        float endStoneCord   = 20f - (StonesCount % 10) / 2;

        CreateStonePossitions(startStoneCord, endStoneCord);
        int reverseStoneIndex = 1;

        for (int i = 1, n = StonesCount; i <= n; i++)
        {
            GameObject go = Instantiate(stonePref, StonesPossitions[i - 1], Quaternion.identity);
            go.GetComponent <StonePrefab>().StoneSetup(((i + 1) / 2) * reverseStoneIndex);
            go.GetComponentInChildren <SpriteRenderer>().sprite = StonesImagesHolder[(i - 1) / 2];
            go.GetComponentInChildren <SpriteRenderer>().transform.localScale = new Vector3(3f, 3f, 1f);
            Stones.Add(go.GetComponent <StonePrefab>());
            go.transform.parent = perant.transform;
            reverseStoneIndex  *= -1;
        }
    }
Esempio n. 10
0
    public void Shoot()
    {
        RaycastHit hit;

        if (Physics.Raycast(fpsCam.transform.position, fpsCam.transform.forward, out hit, range))
        {
            //Debug.Log(hit.transform.name);
            Stones tar = hit.transform.GetComponent<Stones>();

            if (tar != null)
            {
                tar.Damage(damage);
                //hit.rigidbody.AddForce(-hit.normal * hitForce);
                //hit.rigidbody.AddForce(hit.transform.forward * hitForce);
                counter = counter + 1;
                UpdateCounter();
            }

            Instantiate(impact, hit.point, Quaternion.LookRotation(hit.normal));
        }
    }
Esempio n. 11
0
        private bool CheckStones(int x, int y, byte piece)
        {
            int count(int xPos, int yPos, Func <int, int> xInc, Func <int, int> yInc, int result = 0)
            {
                if (x >= Stones.GetLength(0) || y >= Stones.GetLength(1) || x < 0 || y < 0 || Stones[x, y] != piece)
                {
                    return(result);
                }
                else
                {
                    return(count(xInc(x), yInc(y), xInc, yInc, result + 1));
                }
            }

            int diag1 = count(x, y, c => c + 1, c => c + 1) + count(x, y, c => c - 1, c => c - 1);
            int diag2 = count(x, y, c => c + 1, c => c - 1) + count(x, y, c => c - 1, c => c + 1);
            int horz  = count(x, y, c => c + 1, c => c) + count(x, y, c => c - 1, c => c);
            int vert  = count(x, y, c => c, c => c + 1) + count(x, y, c => c, c => c - 1);

            return(diag1 > 5 || diag2 > 5 || horz > 5 || vert > 5);
            //must be > 5 instead of >= because adding two count() calls overcounts by 1 (the first piece is counted twice)
        }
        static void CreateStones(out Stones stones, Int64 stoneCountX)
        {
            // Разделяем камни на 2 массива.
            int e = 0;

            if (stoneCountX % 2 != 0)
            {
                e = 1;
            }

            int path1 = (int)(stoneCountX / 2 + e);
            int path2 = (int)(stoneCountX / 2);

            // Общее количество камней.
            stones = new Stones()
            {
                Part1 = new bool[path1 + 1],
                Part2 = new bool[path2 + 1]
            };
            stones.Part1[0] = true;
            stones.Part2[stones.Part2.Length - 1] = true;
        }
Esempio n. 13
0
        public StoneManager(EarthSpiritCrappa earthSpiritCrappa)
        {
            Main   = earthSpiritCrappa;
            Stones =
                EntityManager <Unit> .Entities.Where(x => x.IsValid && x.ClassId == ClassId.CDOTA_Unit_Earth_Spirit_Stone)
                .ToList();

            EntityManager <Unit> .EntityAdded += (sender, unit) =>
            {
                if (unit.ClassId == ClassId.CDOTA_Unit_Earth_Spirit_Stone)
                {
                    Stones.Add(unit);
                }
            };
            EntityManager <Unit> .EntityRemoved += (sender, unit) =>
            {
                if (unit.ClassId == ClassId.CDOTA_Unit_Earth_Spirit_Stone)
                {
                    Stones.Remove(unit);
                }
            };
        }
Esempio n. 14
0
        public static async Task SaveStones(ulong UserId, ulong Amount)
        {
            using (var DbContext = new SQLiteContext())
            {
                if (DbContext.Stoneses.Where(x => x.UserId == UserId).Count() < 1)
                {
                    DbContext.Stoneses.Add(new Stones()
                    {
                        UserId = UserId,
                        Amount = Amount
                    });
                }
                else
                {
                    Stones Current = DbContext.Stoneses.Where(x => x.UserId == UserId).FirstOrDefault();
                    Current.Amount += Amount;
                    DbContext.Stoneses.Update(Current);
                }

                await DbContext.SaveChangesAsync();
            }
        }
Esempio n. 15
0
 /// <summary>
 /// 重置棋子,一局完了需要重置
 /// </summary>
 public static void Clear()
 {
     Stones.Clear();
     Stones = InitStones();
 }
Esempio n. 16
0
    void Awake()
    {
        GameObject stonesNumUI = GameObject.Find("UI Root/Camera/Anchor-TopRight/Panel/Stones");

        st = stonesNumUI.gameObject.GetComponent <Stones>();
    }
        private void StoneOnMouseLeftButtonDown(object sender, MouseButtonEventArgs mouseButtonEventArgs)
        {
            if (sender is Stone stone)
            {
                switch (TheWindow.Logic.MoveCount)
                {
                case 2:
                {
                    int  rows         = Stones.GetLength(0);
                    int  columns      = Stones.GetLength(1);
                    int  centerRow    = rows - (rows / 2) - 1;
                    int  centerColumn = columns - (columns / 2) - 1;
                    bool valid        = true;
                    for (int i = centerRow - 2; i < centerRow + 3; i++)
                    {
                        for (int j = centerColumn - 2; j < centerColumn + 3; j++)
                        {
                            if (!stone.Equals(Stones[i, j]))
                            {
                                continue;
                            }
                            valid = false;
                            break;
                        }
                        if (!valid)
                        {
                            break;
                        }
                    }
                    if (valid)
                    {
                        stone.CurrentState = StoneState.Black;
                        TheWindow.Logic.SwitchPlayerTurn();
                    }
                    break;
                }

                default:
                    if (stone.CurrentState != StoneState.Open)
                    {
                        return;
                    }
                    stone.CurrentState = TheWindow.Logic.CurrentPlayer == TheWindow.Logic.Player1 ? StoneState.Black : StoneState.White;
                    bool found  = false;
                    int  foundX = 0;
                    int  foundY = 0;
                    for (var i = 0; i < Stones.GetLength(0); i++)
                    {
                        for (var j = 0; j < Stones.GetLength(1); j++)
                        {
                            if (!stone.Equals(Stones[i, j]))
                            {
                                continue;
                            }
                            foundX = j;
                            foundY = i;
                            found  = true;
                            break;
                        }
                        if (found)
                        {
                            break;
                        }
                    }
                    TheWindow.Logic.CheckCapture(foundX, foundY);
                    TheWindow.Logic.CheckFiveInRow(foundX, foundY);
                    TheWindow.Logic.CheckTrias(foundX, foundY);
                    TheWindow.Logic.CheckTessera(foundX, foundY);
                    TheWindow.Logic.SwitchPlayerTurn();
                    break;
                }
            }
        }