/// <summary>
        /// Allows for conversion of <see cref="IUnit"/> derived type.
        /// </summary>
        /// <remarks>
        /// Note: the type <typeparamref name="TN1"/> must be a relative of <typeparamref name="T1"/>.
        /// Note: the type <typeparamref name="TN2"/> must be a relative of <typeparamref name="T2"/>.
        /// </remarks>
        /// <typeparam name="TN1">The new type you want to convert the current scalar's type to.</typeparam>
        /// <typeparam name="TN2">The new type you want to convert the current scalar's type to.</typeparam>
        /// <returns>A new scalar with type of <typeparamref name="TN1"/>, <typeparamref name="TN2"/> who's value has been converted to <typeparamref name="TN1"/>, <typeparamref name="TN2"/>.</returns>
        public Scalar <TN1, TN2> To <TN1, TN2>()
            where TN1 : class, IUnit, new()
            where TN2 : class, IUnit, new()
        {
            TN1 newUnit1 = new TN1();
            TN2 newUnit2 = new TN2();

            foreach (Type t in Unit1.GetType().GetInterfaces())
            {
                if (newUnit1.GetType().GetInterface(t.Name) == null)
                {
                    throw new InvalidCastException(String.Format(CultureInfo.CurrentCulture, "You cannot convert {0} to {1}", Unit1.GetType(), newUnit1.GetType()));
                }
            }
            foreach (Type t in Unit2.GetType().GetInterfaces())
            {
                if (newUnit2.GetType().GetInterface(t.Name) == null)
                {
                    throw new InvalidCastException(String.Format(CultureInfo.CurrentCulture, "You cannot convert {0} to {1}", Unit2.GetType(), newUnit2.GetType()));
                }
            }

            double firstUnitValue = ConvertUnits(newUnit1.GetType(), Unit1.GetType(), Value, Unit1Power);
            double newValue       = ConvertUnits(newUnit2.GetType(), Unit2.GetType(), firstUnitValue, Unit2Power);

            return(new Scalar <TN1, TN2>()
            {
                Value = newValue,
                Unit1 = newUnit1,
                Unit2 = newUnit2,
                Unit1Power = Unit1Power,
                Unit2Power = Unit2Power,
            });
        }
Example #2
0
 //重置
 protected void DeleteAll_Click(object sender, EventArgs e)
 {
     try
     {
         //AwardPeople.Reset();
         //tAchievement.Reset();
         tachievement.Reset();
         tAwardName.Reset();
         dAwardTime.Reset();
         dAwardwSpecies.Reset();
         FirstAward.Reset();
         AwardNum.Reset();
         dAwardForm.Reset();
         dGrade.Reset();
         tRemark.Reset();
         dSecrecyLevel.Reset();
         tGivenAgency.Reset();
         Unit1.Reset();
         Unit2.Reset();
         Unit3.Reset();
         Unit4.Reset();
         Unit5.Reset();
         DropDownList_Sort.Reset();
         Members.Reset();
         PageContext.RegisterStartupScript("clearFile();");
     }
     catch (Exception ex)
     {
         pm.SaveError(ex, this.Request);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            // number
            StringBuilder returnString = new StringBuilder(Value.ToString(CultureInfo.CurrentCulture));

            // first unit
            returnString.AppendFormat(
                " {0}{1}",
                Unit1.GetType().Name,
                ((Unit1Power == 1) ?
                 String.Empty :
                 ("^" + Unit1Power)));

            // divider
            returnString.Append((Unit2Power < 0) ? "/" : "*");

            //second unit
            returnString.AppendFormat(
                "{0}{1}",
                Unit2.GetType().Name,
                ((Math.Abs(Unit2Power) == 1) ?
                 String.Empty :
                 ("^" + Math.Abs(Unit2Power))));

            return(returnString.ToString());
        }
 public override void DeliverPayload(Unit2 hit_unit)
 {
     if (!hit)
     {
         hit = true;
         chainedUnit = hit_unit;
         chainNumber = Actors.Count - 1;
     }
 }
Example #5
0
    void FindPath(Vector3 seekerPos, Vector3 targetPos)
    {
        time = new Stopwatch();
        time.Start();
        Unit2 seekerUnit2 = grid.fromRealPosToUnit2(seekerPos);
        Unit2 targetUnit2 = grid.fromRealPosToUnit2(targetPos);

        openListUnit2 = new List <Unit2>(); // for computing Unit2 of openList ( need to draw path )
        List <Unit2> openList   = new List <Unit2>();
        List <Unit2> closedList = new List <Unit2>();

        openList.Add(seekerUnit2);
        openListUnit2.Add(seekerUnit2); //...

        while (openList.Count > 0)
        {
            Unit2 currentUnit2 = openList[0];
            for (int i = 1; i < openList.Count; i++)
            {
                if ((openList[i].fCost < currentUnit2.fCost) || (openList[i].fCost == currentUnit2.fCost && openList[i].hCost < currentUnit2.hCost))
                {
                    currentUnit2 = openList[i];
                }
            }

            openList.Remove(currentUnit2);
            closedList.Add(currentUnit2);

            if (currentUnit2.realPosition == targetUnit2.realPosition)
            {
                time.Stop();
                ComputePath(seekerUnit2, targetUnit2);
                return;
            }


            foreach (Unit2 neighbour in grid.GetNeighbours(currentUnit2))
            {
                if (!neighbour.walkable || closedList.Contains(neighbour))
                {
                    continue;
                }

                int pathToNeighbour = currentUnit2.gCost + GetDistance(currentUnit2, neighbour);
                if (pathToNeighbour < neighbour.gCost || !openList.Contains(neighbour))
                {
                    neighbour.gCost  = pathToNeighbour;
                    neighbour.hCost  = GetDistance(neighbour, targetUnit2);
                    neighbour.parent = currentUnit2;
                    openList.Add(neighbour);
                    openListUnit2.Add(neighbour); // ...
                }
            }
        }
    }
Example #6
0
    int GetDistance(Unit2 Unit21, Unit2 Unit22)
    {
        int dstX = Mathf.Abs(Unit21.x - Unit22.x);
        int dstY = Mathf.Abs(Unit21.y - Unit22.y);

        if (dstX > dstY)
        {
            return(14 * dstY + 10 * (dstX - dstY));
        }
        return(14 * dstX + 10 * (dstY - dstX));
    }
Example #7
0
 protected override void AddDescriptions()
 {
     base.AddDescriptions();
     AddDescription("Code:" + Code.ToStr());
     AddDescription("Name:" + Name.ToStr());
     AddDescription("Specification:" + Specification.ToStr());
     AddDescription("ShortName:" + ShortName.ToStr());
     AddDescription("Unit:" + Unit.ToStr());
     AddDescription("Unit2:" + Unit2.ToStr());
     AddDescription("Color:" + Color.ToStr());
     AddDescription("Conversion:" + Conversion.ToStr());
 }
        public override void Cast(Unit2 unit)
        {
            Vector2 lastPosition = Owner.Center;
            Vector2 nextPosition = lastPosition;

            //while hasn't hit
            for (int i = 0; i < 20; i++)
            {
                Actors.Add(new Actor(this, nextPosition));
                lastPosition = nextPosition;
                //nextPosition = lastPosition + Vector2.Normalize(target_point - lastPosition) * 16;
            }
        }
Example #9
0
    void ComputePath(Unit2 startUnit2, Unit2 endUnit2)
    {
        Unit2        currentUnit2 = endUnit2;
        List <Unit2> newPath      = new List <Unit2>(); // for computing shotest path

        while (currentUnit2.realPosition != startUnit2.realPosition)
        {
            newPath.Add(currentUnit2);
            currentUnit2 = currentUnit2.parent;
        }
        newPath.Reverse();
        path = newPath;
    }
Example #10
0
    void CreateGrid()
    {
        grid = new Unit2[Unit2GridSizeX, Unit2GridSizeY];
        // right (1,0,0) , forward (0,0,1)
        Vector3 bottomLeftCorner = transform.position - Vector3.right * realGridSize.x / 2 - Vector3.forward * realGridSize.y / 2;

        for (int x = 0; x < Unit2GridSizeX; x++)
        {
            for (int y = 0; y < Unit2GridSizeY; y++)
            {
                //1.5 Unit2
                Vector3 Unit2Position = bottomLeftCorner + Vector3.right * (x * nodeDiameter + nodeRadius) + Vector3.forward * (y * nodeDiameter + nodeRadius);
                // check if there is a collision
                bool walkable = !(Physics.CheckSphere(Unit2Position, nodeRadius, obstacleMask));
                grid[x, y] = new Unit2(walkable, Unit2Position, x, y);
            }
        }
    }
Example #11
0
 void DrawFunc()
 {
     if (drawOnlyPath)
     {
         foreach (Unit2 n in grid)
         {
             if (pathFinding2.path != null && pathFinding2.path.Contains(n))
             {
                 Gizmos.color = Color.black;
                 Gizmos.DrawCube(n.realPosition, new Vector3(1, 0.05f, 1) * (nodeDiameter - .1f));
             }
         }
     }
     else
     {
         foreach (Unit2 n in grid)
         {
             Gizmos.color = (n.walkable) ? Color.white : Color.red;
             Unit2 seekerUnit2 = fromRealPosToUnit2(pathFinding2.seeker.transform.position);
             Unit2 targetUnit2 = fromRealPosToUnit2(pathFinding2.target.transform.position);
             if (pathFinding2.path != null)
             {
                 if (pathFinding2.openListUnit2.Contains(n))
                 {
                     Gizmos.color = Color.grey;
                 }
                 if (pathFinding2.path.Contains(n))
                 {
                     Gizmos.color = Color.black;
                 }
             }
             if (n.realPosition == seekerUnit2.realPosition)
             {
                 Gizmos.color = pathFinding2.seeker.GetComponent <Renderer>().material.color;
             }
             if (n.realPosition == targetUnit2.realPosition)
             {
                 Gizmos.color = pathFinding2.target.GetComponent <Renderer>().material.color;
             }
             Gizmos.DrawCube(n.realPosition, new Vector3(1, 0.05f, 1) * (nodeDiameter - .1f));
         }
     }
 }
Example #12
0
    public List <Unit2> GetNeighbours(Unit2 Unit2)
    {
        List <Unit2> neighbours = new List <Unit2>();

        for (int x = -1; x <= 1; x++)
        {
            for (int y = -1; y <= 1; y++)
            {
                int posX = Unit2.x + x;
                int posY = Unit2.y + y;
                if ((x == 0 && y == 0) || !(posX >= 0 && posX < Unit2GridSizeX && posY >= 0 && posY < Unit2GridSizeY))
                {
                    continue;
                }
                neighbours.Add(grid[posX, posY]);
            }
        }

        return(neighbours);
    }
    // Select a random enemy unit adjacent to an ally and shoot em
    IEnumerator AssassinActiveActivate()
    {
        mActiveActivated = true;
        while (mTurnGoing)
        {
            yield return(null);
        }

        List <GameObject> mFriendlyList = mFlowController.GetComponent <FlowController>().GetFriendlyUnits().GetRange(0, mFlowController.GetComponent <FlowController>().GetFriendlyUnits().Count);

        mFriendlyList.Sort((a, b) => 1 - 2 * Random.Range(0, 1));

        foreach (GameObject Unit in mFriendlyList)
        {
            if (Unit == gameObject)
            {
                continue;
            }
            List <GameObject> AdjacentList = Unit.GetComponent <Movement>().GetAllAdjacentCharacters();
            if (AdjacentList.Count > 0)
            {
                foreach (GameObject Unit2 in AdjacentList)
                {
                    if (Unit2.tag == "EnemyUnit")
                    {
                        Unit2.GetComponent <CharacterStats>().MaxHealth -= AttackDamage;

                        if (Unit2.GetComponent <CharacterStats>().MaxHealth <= 0)
                        {
                            Unit2.GetComponent <CharacterStats>().MaxHealth = 1;
                        }
                        mActiveActivated = false;
                        yield break;
                    }
                }
            }
        }
        mActiveActivated = false;
    }
Example #14
0
        static void Main(string[] args)
        {
            Console.Clear();
            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("(_ ___)-._.-=-._.-=-._.-=-._.-=-._.-=-._.._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-(_ ___) \n");
            Console.WriteLine("                     .-\"\"\"\"-.        .-\"\"\"\"-. \n");
            Console.WriteLine("                    /        \\      /        \\ \n");
            Console.WriteLine("                   /_        _\\    /_        _\\ \n");
            Console.WriteLine("                  // \\      / \\   // \\      / \\ \n");
            Console.WriteLine("                  |\\__\\    /__/|  |\\__\\    /__/| \n");
            Console.WriteLine("                   \\    ||    /    \\    ||    /\\ \n");
            Console.WriteLine("                    \\        /      \\        /\n");
            Console.WriteLine("                     \\  __  /        \\  __  /  \n");
            Console.WriteLine("                      '.__.'          '.__.' \n");
            Console.WriteLine("                       |  |            |  |\n");
            Console.WriteLine("                       |  |            |  |\n");
            Console.WriteLine("                         👽 Ninjanauts 👽 \n");
            Console.WriteLine("\n");
            Console.WriteLine("(_ ___)-._.-=-._.-=-._.-=-._.-=-._.-=-._.._.-=-._.-=-._.-=-._.-=-._.-=-._.-=-._.-(_ ___) \n");
            Console.ResetColor();
            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("Planet Earth 🌍 year 2020... \n \n  Earth is corrupted with viruses and pollution, \n we have no choice left, but to send some brave people to space, \n their journey might not be successful, but they are our only hope... \n");
            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();

            Console.Clear();
            Console.WriteLine("So far we have two candidates, let's see who is smarter, the will be the \"chose one\", he will be sent to space \n");
            Console.ResetColor();
            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();

            Console.Clear();
            Library word  = new Library();
            Unit1   unit1 = new Unit1("ᕙ(▀̿̿Ĺ̯̿̿▀̿ ̿) ᕗ SAM the nerd");
            Unit2   unit2 = new Unit2("(‡▼益▼) geeky JACK");

            Console.BackgroundColor = ConsoleColor.Red;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine("Let's the epic battle begin \n");
            Console.WriteLine($"{unit1.Name} vs. {unit2.Name} \n");
            Console.ResetColor();
            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();

            //Console.Clear();
            while (!unit2.IsFull || !unit1.IsFull)
            {
                unit1.Consume(word.Serve());
                unit2.Consume(word.Serve());
            }

            Console.BackgroundColor = ConsoleColor.Red;
            Console.ForegroundColor = ConsoleColor.Black;
            Console.WriteLine($"{unit1.Name} learned {unit1.ConsumptionHistory.Count} books & {unit2.Name} learned {unit2.ConsumptionHistory.Count} books \n");

            Console.WriteLine("Press any key to continue...\n");
            Console.ReadKey();
            Console.Clear();

            if (unit1.ConsumptionHistory.Count > unit2.ConsumptionHistory.Count)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("Mewnwhile in space...music plays\n");
                Console.WriteLine("Ground control to major tom ♪ ♪ ♪ \n  take your protein pills and put your helmet on...  ♫ ♫ ♫ \n our ninjanaut 🙭 is in space!...\n");
                Console.WriteLine($"The earth is saved...ninjanaut 🙭 {unit1.Name} is in space!");
                Console.ResetColor();
            }
            else if (unit2.ConsumptionHistory.Count > unit1.ConsumptionHistory.Count)
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine("Mewnwhile in space...music plays\n");
                Console.WriteLine("Ground control to major tom ♪ ♪ ♪ \n  take your protein pills and put your helmet on...  ♫ ♫ ♫ \n our ninjanaut 🙭 is in space!...\n");
                Console.WriteLine($"The earth is saved...ninjanaut 🙭 {unit2.Name} is in space!");
                Console.ResetColor();
            }
            else
            {
                Console.BackgroundColor = ConsoleColor.Red;
                Console.ForegroundColor = ConsoleColor.Black;
                Console.WriteLine($"It looks to be like ☠ ninjanauts ☠ are both equal dumb \n the Earth is doomed, sorry for your loss ☠ ");
                Console.ResetColor();
                Console.ResetColor();
            }

            // Console.Clear();


            // Console.WriteLine("Press any key to continue...\n");
            // Console.ReadKey();
        }
 public BurningGrasp(Unit2 owner)
     : base(owner)
 {
     //sa = new Animation(AbilityTexture, Constants.DefaultFrameTime, false);
 }