Esempio n. 1
0
 public void CreateBug(BugType Type)
 {
     if (!_isBug)
     {
         StartCoroutine(BugAim(50, _Timer));
     }
 }
Esempio n. 2
0
 public RequestBug(RequestStatus status, BugType bugtype, string description, int submittedByID)
 {
     this.Status = status;
     this.BugType = bugtype;
     this.Description = description;
     this.SubmittedByUserId = submittedByID;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            BugType bugType = db.BugTypes.Find(id);

            db.BugTypes.Remove(bugType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 4
0
 public Piece(bool side, BugType type, int number)
 {
     this.side    = side;
     this.type    = type;
     this.number  = number;
     this.blocked = false;
     position     = null;
 }
        /// <summary>
        /// Process record type.
        /// </summary>
        /// <remarks>
        /// It seems type can be null for old bugs.
        /// So in that case it is handled as Unspecified.
        /// </remarks>
        private static BugType ProcessType(Record record)
        {
            BugType type    = BugType.Bug;
            string  typeStr = record[TypeCol];
            bool    found   = typeStr != null?s_typeMappings.TryGetValue(typeStr, out type) : false;

            return(found ? type : BugType.Unspecified);
        }
Esempio n. 6
0
        /// <summary>
        /// Constructs a bug for the provided bug type and name.
        /// </summary>
        /// <param name="bugType"> The bug type for the activity.</param>
        /// <param name="name"The name for the bug.</param>
        public Bug(BugType bugType, string name = null)
        {
            Id = (int)bugType;

            // If we don't have a name argument,
            // then use the string representation of the bug type for the name.
            Name = name ?? bugType.ToString();
        }
Esempio n. 7
0
 public RequestBug(int id, RequestStatus status, List<Remark> remarks, BugType bugtype, string description, int submittedByID)
 {
     this.Id = id;
     this.Status = status;
     this.Remarks = remarks;
     this.BugType = bugtype;
     this.Description = description;
     this.SubmittedByUserId = submittedByID;
 }
Esempio n. 8
0
    private PlayerMovement GetPlayerPrefabForBugType(BugType bugType)
    {
        switch (bugType)
        {
        case BugType.Random: return(_playerBugPrefabs[Random.Range(0, _playerBugPrefabs.Length)]);

        default:             return(_playerBugPrefabs.FirstOrDefault(x => x.GetBugType() == bugType));
        }
    }
 public ActionResult Edit([Bind(Include = "Id,TypeOfBug")] BugType bugType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bugType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(bugType));
 }
        public ActionResult Create([Bind(Include = "Id,TypeOfBug")] BugType bugType)
        {
            if (ModelState.IsValid)
            {
                db.BugTypes.Add(bugType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(bugType));
        }
Esempio n. 11
0
 void UpdateTips(params object[] objs)
 {
     if (objs.Length == 2)
     {
         BugType bt  = (BugType)objs[0];
         string  msg = (string)objs[1];
         if (tipArea != null)
         {
             tipArea.text += msg + "\n";
         }
     }
 }
        // GET: BugTypes/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BugType bugType = db.BugTypes.Find(id);

            if (bugType == null)
            {
                return(HttpNotFound());
            }
            return(View(bugType));
        }
Esempio n. 13
0
        public static bool IsEnabled(BugType bugType, ExpansionPieces expansionPieces)
        {
            switch (bugType)
            {
            case BugType.Mosquito:
                return((expansionPieces & ExpansionPieces.Mosquito) == ExpansionPieces.Mosquito);

            case BugType.Ladybug:
                return((expansionPieces & ExpansionPieces.Ladybug) == ExpansionPieces.Ladybug);

            case BugType.Pillbug:
                return((expansionPieces & ExpansionPieces.Pillbug) == ExpansionPieces.Pillbug);

            default:
                return(true);
            }
        }
Esempio n. 14
0
        public static void IterateOverWeights(Action <BugType, BugTypeWeight> action)
        {
            if (null == action)
            {
                throw new ArgumentNullException("action");
            }

            for (int bugTypeInt = 0; bugTypeInt < EnumUtils.NumBugTypes; bugTypeInt++)
            {
                BugType bugType = (BugType)bugTypeInt;
                for (int bugTypeWeightInt = 0; bugTypeWeightInt < NumBugTypeWeights; bugTypeWeightInt++)
                {
                    BugTypeWeight bugTypeWeight = (BugTypeWeight)bugTypeWeightInt;

                    action(bugType, bugTypeWeight);
                }
            }
        }
        /// <summary>
        /// Create revision based on provided information.
        /// </summary>
        private void ProcessRevision(int number, int revision, DateTime date,
                                     BugType type, BugStatus status, string summary,
                                     BugSeverity?severity, int?priority, Application app,
                                     Module module, SubModule subModule, Release foundRelease, Release targetRelease,
                                     Person contributor, Person leader, Person developer, Person tester)
        {
            // Check prerequisites
            if (app == null)
            {
                throw new Exception(
                          String.Format("Application isn't specified for bug={0}, revision={1}", number, revision));
            }
            if (contributor == null)
            {
                throw new Exception(
                          String.Format("Contributor isn't specified for bug={0}, revision={1}", number, revision));
            }

            Revision rev = new Revision
            {
                BugNumber       = number,
                Rev             = revision,
                Date            = date,
                Type            = type,
                Status          = status,
                Summary         = summary,
                Severity        = severity,
                Priority        = priority,
                AppId           = app.Id,
                ModuleId        = module != null ? (int?)module.Id : null,
                SubModuleId     = subModule != null ? (int?)subModule.Id : null,
                FoundReleaseId  = foundRelease != null ? (int?)foundRelease.Id : null,
                TargetReleaseId = targetRelease != null ? (int?)targetRelease.Id : null,
                ContributorId   = contributor.Id,
                TeamLeaderId    = leader != null ? (int?)leader.Id : null,
                DeveloperId     = developer != null ? (int?)developer.Id : null,
                TesterId        = tester != null ? (int?)tester.Id : null
            };

            m_provider.CreateRevision(rev);
        }
Esempio n. 16
0
        private void CreateNewSpawner(BugType bugType = BugType.HealthAttacker)
        {
            // Pick location
            Vector2 spawnerLocation = GetRandomPosition(bugType == BugType.SkillStealer ? spawnerZone2 : spawnerZone);

            // Create spawner
            BugSpawner prefabToSpawn;

            if (bugType == BugType.HealthAttacker)
            {
                prefabToSpawn = healthAttackerSpawnerPrefab;
            }
            else if (bugType == BugType.SkillStealer)
            {
                prefabToSpawn = skillThiefSpawnerPrefab;
            }
            else
            {
                throw new Exception("Unknown spawner type: " + bugType);
            }

            var spawner = Instantiate(prefabToSpawn);

            spawner.bugType            = bugType;
            spawner.transform.position = spawnerLocation;

            float randomRotation = Random.Range(0f, 1f);

            if (randomRotation < .25f)
            {
                spawner.transform.Rotate(Vector3.forward, 90);
            }
            else if (randomRotation < .5f)
            {
                spawner.transform.Rotate(Vector3.forward, 180);
            }
            else if (randomRotation < .75f)
            {
                spawner.transform.Rotate(Vector3.forward, 270);
            }
        }
Esempio n. 17
0
        private static double CalculateBoardScore(BoardMetrics boardMetrics, MetricWeights metricWeights)
        {
            double score = 0;

            foreach (PieceName pieceName in EnumUtils.PieceNames)
            {
                BugType bugType = EnumUtils.GetBugType(pieceName);

                double colorValue = EnumUtils.GetColor(pieceName) == PlayerColor.White ? 1.0 : -1.0;

                score += colorValue * metricWeights.Get(bugType, BugTypeWeight.InPlayWeight) * boardMetrics[pieceName].InPlay;
                score += colorValue * metricWeights.Get(bugType, BugTypeWeight.IsPinnedWeight) * boardMetrics[pieceName].IsPinned;
                score += colorValue * metricWeights.Get(bugType, BugTypeWeight.IsCoveredWeight) * boardMetrics[pieceName].IsCovered;
                score += colorValue * metricWeights.Get(bugType, BugTypeWeight.NoisyMoveWeight) * boardMetrics[pieceName].NoisyMoveCount;
                score += colorValue * metricWeights.Get(bugType, BugTypeWeight.QuietMoveWeight) * boardMetrics[pieceName].QuietMoveCount;
                score += colorValue * metricWeights.Get(bugType, BugTypeWeight.FriendlyNeighborWeight) * boardMetrics[pieceName].FriendlyNeighborCount;
                score += colorValue * metricWeights.Get(bugType, BugTypeWeight.EnemyNeighborWeight) * boardMetrics[pieceName].EnemyNeighborCount;
            }

            return(score);
        }
Esempio n. 18
0
        private MetricWeights GetGradient(BoardMetrics boardMetrics)
        {
            MetricWeights gradient = new MetricWeights();

            foreach (PieceName pieceName in EnumUtils.PieceNames)
            {
                BugType bugType = EnumUtils.GetBugType(pieceName);

                double colorValue = EnumUtils.GetColor(pieceName) == PlayerColor.White ? 1.0 : -1.0;

                gradient.Set(bugType, BugTypeWeight.InPlayWeight, gradient.Get(bugType, BugTypeWeight.InPlayWeight) + colorValue * boardMetrics[pieceName].InPlay);
                gradient.Set(bugType, BugTypeWeight.IsPinnedWeight, gradient.Get(bugType, BugTypeWeight.IsPinnedWeight) + colorValue * boardMetrics[pieceName].IsPinned);
                gradient.Set(bugType, BugTypeWeight.IsCoveredWeight, gradient.Get(bugType, BugTypeWeight.IsCoveredWeight) + colorValue * boardMetrics[pieceName].IsCovered);
                gradient.Set(bugType, BugTypeWeight.NoisyMoveWeight, gradient.Get(bugType, BugTypeWeight.NoisyMoveWeight) + colorValue * boardMetrics[pieceName].NoisyMoveCount);
                gradient.Set(bugType, BugTypeWeight.QuietMoveWeight, gradient.Get(bugType, BugTypeWeight.QuietMoveWeight) + colorValue * boardMetrics[pieceName].QuietMoveCount);
                gradient.Set(bugType, BugTypeWeight.FriendlyNeighborWeight, gradient.Get(bugType, BugTypeWeight.FriendlyNeighborWeight) + colorValue * boardMetrics[pieceName].FriendlyNeighborCount);
                gradient.Set(bugType, BugTypeWeight.EnemyNeighborWeight, gradient.Get(bugType, BugTypeWeight.EnemyNeighborWeight) + colorValue * boardMetrics[pieceName].EnemyNeighborCount);
            }

            return(gradient);
        }
Esempio n. 19
0
        public static bool TryParseKeyName(string key, out BugType bugType, out BugTypeWeight bugTypeWeight)
        {
            if (!string.IsNullOrWhiteSpace(key))
            {
                try
                {
                    string[] split = key.Split(KeySeperator[0]);

                    if (Enum.TryParse(split[split.Length - 1], out bugTypeWeight))
                    {
                        if (Enum.TryParse(split[split.Length - 2], out bugType))
                        {
                            return(true);
                        }
                    }
                }
                catch (Exception) { }
            }

            bugType       = default(BugType);
            bugTypeWeight = default(BugTypeWeight);
            return(false);
        }
Esempio n. 20
0
        private string Label()
        {
            string FinalString;

            if (BugName.ToLower().Trim() == "morto")
            {
                FinalString = BugName;
            }
            else
            {
                FinalString  = BugName.ToUpper();
                FinalString += "\n" + BugType.ToLower();
                if (RelativeAge)
                {
                    FinalString += "\n" + (AgeNow / AgeMax).ToString("0.00");
                }
                else
                {
                    FinalString += "\n" + AgeNow.ToString() + @" / " + AgeMax.ToString();
                }
            }
            return(FinalString);
        }
Esempio n. 21
0
        public void Set(BugType bugType, BugTypeWeight bugTypeWeight, double value)
        {
            int key = GetKey(bugType, bugTypeWeight);

            _bugTypeWeights[key] = value;
        }
Esempio n. 22
0
        public double Get(BugType bugType, BugTypeWeight bugTypeWeight)
        {
            int key = GetKey(bugType, bugTypeWeight);

            return(_bugTypeWeights[key]);
        }
Esempio n. 23
0
 private static int GetKey(BugType bugType, BugTypeWeight bugTypeWeight)
 {
     return(((int)bugType * NumBugTypeWeights) + (int)bugTypeWeight);
 }
Esempio n. 24
0
 public Bug()
 {
     this.type = (BugType)rng.Next(0, 2);
 }
Esempio n. 25
0
 public static string GetKeyName(BugType bugType, BugTypeWeight bugTypeWeight)
 {
     return(string.Join(KeySeperator, bugType.ToString(), bugTypeWeight.ToString()));
 }
Esempio n. 26
0
    // Use this for initialization
    void Start()
    {
        //Change the plant to have a color same as one of the bugs on screen
        var MultiObjGameManager = GameObject.Find("MultiObjGameManager");
        var bugList             = MultiObjGameManager.GetComponent <MultiObjGameManager> ().colors;

        Debug.Log("multiobjGameManager: " + MultiObjGameManager);
        if (MultiObjGameManager)
        {
            int randomBug = Random.Range(0, bugList.Count);
            Debug.Log("type of bug color: " + bugList [randomBug].GetComponent <CloakControl> ().type);
            correctBugType = bugList [randomBug].GetComponent <CloakControl> ().type;

            if (correctBugType == BugType.Blue)
            {
                bugColor = Color.blue;
            }
            else if (correctBugType == BugType.Green)
            {
                bugColor = Color.green;
            }
            else if (correctBugType == BugType.Red)
            {
                bugColor = Color.red;
            }
            else if (correctBugType == BugType.White)
            {
                bugColor = Color.white;
            }
            else if (correctBugType == BugType.Yellow)
            {
                bugColor = Color.yellow;
            }
        }

        //start plant health
        int health = 100;

        //Lets the plant only be hit once
        notHitYet = true;

        //Set animator script parameter value
        gameObject.GetComponent <Animator> ().SetFloat("animHealth", health);

        PlantSpawner plantSpawner = GameObject.Find("PlantSpawner").GetComponent <PlantSpawner>();

        FieldInfo info = Util.getFieldInfo(field);

        var bottomLeftCorner = new Vector3(info.lowerX, info.lowerY, 0);
        var upperRightCorner = new Vector3(info.upperX, info.upperY, 0);

        var blank = wayPointReference;

        topBound    = Instantiate(blank, upperRightCorner, transform.rotation) as WayPoint;
        bottomBound = Instantiate(blank, bottomLeftCorner, transform.rotation) as WayPoint;
        leftBound   = Instantiate(blank, bottomLeftCorner, transform.rotation) as WayPoint;
        rightBound  = Instantiate(blank, upperRightCorner, transform.rotation) as WayPoint;

        //TODO: change this to one of the actual colors
//		this.GetComponent<Renderer>().material.color = Util.randomColor ();
        this.GetComponent <Renderer>().material.color = bugColor;

//		Debug.Log (health);
        InvokeRepeating("Depleting", depleteSeconds, depleteSeconds);

        var player = GameObject.Find("Player");

        playerCircleCollider = player.GetComponent <CircleCollider2D> ();
    }
Esempio n. 27
0
 public void SetNextBugTypeToSpawn(BugType bugType)
 {
     _nextBugTypeToSpawn = bugType;
 }
Esempio n. 28
0
 //Log
 //public void Log(BugType type, string str)
 //{
 //    Dispath(AppEvent.appLog, type, str);
 //    debugRecord(str, type);
 //}
 void debugRecord(string str, BugType type)
 {
     if (AppConst.openDebugRecord)
     {
     }
 }
Esempio n. 29
0
 public Bug()
 {
     this.type = BugType.Yellow;
 }
Esempio n. 30
0
    // Use this for initialization
    void Start()
    {
        //Change the plant to have a color same as one of the bugs on screen
        var MultiObjGameManager = GameObject.Find("MultiObjGameManager");
        var bugList = MultiObjGameManager.GetComponent<MultiObjGameManager> ().colors;
        Debug.Log ("buglist: " + bugList.Count);
        if (MultiObjGameManager) {
            int randomBug = Random.Range (0, bugList.Count);
        //	Debug.Log ("type of bug color: " + bugList [randomBug].GetComponent<CloakControl> ().type);
            correctBugType = bugList [randomBug].GetComponent<CloakControl> ().type;

            if(correctBugType == BugType.Blue){
                bugColor = Color.blue;
            }
            else if(correctBugType == BugType.Green){
                bugColor = Color.green;
            }
            else if(correctBugType == BugType.Red){
                bugColor = Color.red;
            }
            else if(correctBugType == BugType.White){
                bugColor = Color.white;
            }
            else if(correctBugType == BugType.Yellow){
                bugColor = Color.yellow;
            }
        }

        //start plant health
        int health = 100;

        //Lets the plant only be hit once
        notHitYet = true;

        //Set animator script parameter value
        gameObject.GetComponent<Animator> ().SetFloat("animHealth", health);

        PlantSpawner plantSpawner = GameObject.Find ("PlantSpawner").GetComponent<PlantSpawner>();

        FieldInfo info = Util.getFieldInfo (field);

        var bottomLeftCorner = new Vector3 (info.lowerX, info.lowerY, 0);
        var upperRightCorner = new Vector3 (info.upperX, info.upperY, 0);

        var blank = wayPointReference;
        topBound = Instantiate (blank, upperRightCorner, transform.rotation) as WayPoint;
        bottomBound = Instantiate (blank, bottomLeftCorner, transform.rotation) as WayPoint;
        leftBound = Instantiate (blank, bottomLeftCorner, transform.rotation) as WayPoint;
        rightBound = Instantiate (blank, upperRightCorner, transform.rotation) as WayPoint;

        //TODO: change this to one of the actual colors
        //		this.GetComponent<Renderer>().material.color = Util.randomColor ();
        this.GetComponent<Renderer>().material.color = bugColor;

        //		Debug.Log (health);
        InvokeRepeating ("Depleting", depleteSeconds, depleteSeconds);

        var player = GameObject.Find ("Player");
        playerCircleCollider = player.GetComponent<CircleCollider2D> ();
    }
        /// <summary>
        /// Reads query results from stream and fills database.
        /// </summary>
        /// <remarks>
        /// Prerequisite for normal functioning of this method
        /// is initialized empty storage. But this particular
        /// method doesn't initialize storage itself. So prior
        /// calling this method storage shall be initialized.
        /// </remarks>
        public void FillStorage(TextReader reader)
        {
            // Create records enumerator from stream
            IEnumerator <Record> records = QueryResultParser.CreateRecordsEnumerator(reader);

            // Initialize caches
            m_appCache       = new Dictionary <string, Application>();
            m_moduleCache    = new Dictionary <ComplexKey, Module>();
            m_subModuleCache = new Dictionary <ComplexKey, SubModule>();
            m_relCache       = new Dictionary <ComplexKey, Release>();
            m_personCache    = new Dictionary <string, Person>();

            int current = 0;

            // Enumerate records (actually revisions)
            while (records.MoveNext())
            {
                // Take current record from parser
                Record record = records.Current;

                // Process number
                int number = ProcessNumber(record);

                // Process revision number
                int revision = ProcessRevisionNumber(record);

                // Process short description
                string summary = ProcessSummary(record);

                // Process date
                DateTime date = ProcessDate(record);

                // Process record type (could be null)
                BugType type = ProcessType(record);

                // Process status
                BugStatus status = ProcessStatus(record);

                // Process severity
                BugSeverity?severity = ProcessSeverity(record);

                // Process priority
                int?priority = ProcessPriority(record);

                // Process application
                Application app = ProcessApp(record);

                Module    module        = null;
                SubModule subModule     = null;
                Release   foundRelease  = null;
                Release   targetRelease = null;
                // Process some fields only if application is specified
                if (app != null)
                {
                    // Process module
                    module = ProcessModule(record, app);
                    // Don't process sub module if module is null
                    if (module != null)
                    {
                        // Process sub
                        subModule = ProcessSubModule(record, module);
                    }

                    // Process found release
                    foundRelease = ProcessRelease(record, app, FoundRelCol);
                    // Process target release
                    targetRelease = ProcessRelease(record, app, TargetRelCol);
                }

                // Process contributor
                Person contributor = ProcessPerson(record, ContributorCol);
                // Process team leader
                Person leader = ProcessPerson(record, LeaderCol);
                // Process developer
                Person developer = ProcessPerson(record, DevCol);
                // Process tester
                Person tester = ProcessPerson(record, QaCol);

                // Process revision
                ProcessRevision(number, revision, date, type, status,
                                summary, severity, priority, app, module,
                                subModule, foundRelease,
                                targetRelease, contributor, leader, developer, tester);

                current++;
                // Notify progress
                FireProgressChanged(current);
            }
        }