Exemplo n.º 1
0
 public virtual void OnCollisionStay2D(Collision2D collision)
 {
     if (!dead && !antiBodyDisable)
     {
         if (collision.transform.GetComponent <RedCell>() != null)
         {
             /* if (!disperse && dispersionCooldown.CountDown())
              * {
              *   disperse = !disperse;
              * }*/
             currentCell = collision.transform.GetComponent <RedCell>();
             currentCell.DecreaseVitality(minusDamage);
             nutrition += Time.deltaTime * plusDamage;
             if (nutrition >= 5f)
             {
                 Duplicate();
                 nutrition = 0;
             }
         }
     }
     if (!dead)
     {
         if (collision.transform.GetComponent <WhiteCell>() != null)
         {
             DecreaseVitality();
         }
     }
 }
Exemplo n.º 2
0
 private bool IsValid(RedCell Entity)
 {
     if (Entity.UsedDate > Entity.ExpirationDate || Entity.Quantity < 0)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
        public RedCell Add(DateTime ExpirationDate, DateTime?UsedDate, int Quantity)
        {
            RedCell p = new RedCell()
            {
                ExpirationDate = ExpirationDate,
                UsedDate       = UsedDate,
                Quantity       = Quantity
            };

            Repository.Add(p);

            return(p);
        }
Exemplo n.º 4
0
 public void Add(RedCell Entity)
 {
     if (IsValid(Entity))
     {
         using (var context = new DatabaseContainer())
         {
             context.RedCellSet.Add(Entity);
             try
             {
                 context.SaveChanges();
             }
             catch (Exception)
             {
                 throw new ArgumentException("There is already a RedCell result with that id");
             }
         }
     }
 }
        public ActionResult DonationComplete(AddDonateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("AddDonation", model));
            }

            if (model.Plasma < 0 || model.RedCell < 0 || model.Thrombocytes < 0)
            {
                ModelState.AddModelError(String.Empty, "Quantity cannot be 0");
                return(View("AddDonation", model));
            }
            else if (model.Date < DateTime.Today)
            {
                ModelState.AddModelError(String.Empty, "Date cannot be before today");
                return(View("AddDonation", model));
            }
            else
            {
                DonationAppointment app = _donationAppointmentService.GetById(model.AppointmentId);
                _donationAppointmentService.Update(app.Id, app.AppointmentDate, app.RequestId, true, app.ProfileId,
                                                   app.TransfusionCenterId);
                Plasma       p = _plasmaService.Add(model.Date.AddMonths(2), null, model.Plasma);
                RedCell      r = _redCellService.Add(model.Date.AddDays(42), null, model.RedCell);
                Thrombocytes t = _thrombocytesService.Add(model.Date.AddDays(5), null, model.Thrombocytes);

                BloodSeparation b = _bloodSeparation.Add(p.Id, r.Id, t.Id);

                Donation d = _donationService.Add(app.RequestId, model.Plasma + model.RedCell + model.Thrombocytes, model.Date, false,
                                                  StatusEnum.Preparated, app.ProfileId, b.Id, model.BloodType);

                LabResult lb = _labResultService.Add(false, false, false, false, false, "None", d.Id);
            }


            return(View("AddDonation", model));
        }
Exemplo n.º 6
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        HealthScript           playerHealth = GetComponent <HealthScript> ();
        OrangeCell             orangeCell   = collision.gameObject.GetComponent <OrangeCell>();
        RedCell                redCell      = collision.gameObject.GetComponent <RedCell>();
        BlueCell               blueCell     = collision.gameObject.GetComponent <BlueCell>();
        NanitoControllerScript nanito       = nanitoGO.GetComponent <NanitoControllerScript>();

        if (collision.gameObject.tag == "orange")
        {
            if (nanito.shieldGO.activeSelf == true)
            {
                nanito.damagePlayer = false;
                nanito.shieldHits--;
                Debug.Log("shield hit");
                //orangeCell = null;
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, nanito.respawnPosX, nanito.respawnPosY, true);
                }
            }
            else
            {
                nanito.damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, nanito.respawnPosX, nanito.respawnPosY, false);
                }
            }
        }

        if (collision.gameObject.tag == "red")
        {
            if (nanito.shieldGO.activeSelf == true)
            {
                nanito.damagePlayer = false;
                nanito.shieldHits--;
                Debug.Log("shield hit");
                //orangeCell = null;
            }
            else
            {
                nanito.damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(redCell.damage, nanito.respawnPosX, nanito.respawnPosY, false);
                }
            }
        }

        if (collision.gameObject.tag == "blue")
        {
            if (nanito.shieldGO.activeSelf == true)
            {
                nanito.damagePlayer = false;
                nanito.shieldHits--;
                Debug.Log("shield hit");
                //orangeCell = null;
            }
            else
            {
                nanito.damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(blueCell.damage, nanito.respawnPosX, nanito.respawnPosY, false);
                }
            }
        }
    }
        private void InitCells() 
        {
            _calendar[,] tmp = new _calendar[6,7];

            for (int i = 0; i < tmp.GetUpperBound(0); i++)
            {
                int[] n = mHelper.GetDigitsForRow(i);
                for(int d=0; d<n.Length; d++)
                {
                    if(mHelper.IsWithinCurrentMonth(i, d))
                        tmp[i,d] = new _calendar(n[d], true);
                    else
                        tmp[i,d] = new _calendar(n[d]);        
                }
            }

            DateTime today = DateTime.Now;
            int thisDay = 0;
            mToday = null;
            if(mHelper.Year == today.Year && mHelper.Month == today.Month)
                thisDay = today.Day;

            // build cells
            Rect Bound = new Rect(CELL_MARGIN_LEFT, CELL_MARGIN_TOP, CELL_WIDTH+CELL_MARGIN_LEFT, CELL_HEIGH+CELL_MARGIN_TOP);

            int bound0 = mCells.GetUpperBound(0);
            int bound1 = mCells.GetUpperBound(1);
            for (int week = 0; week < bound0; week++)
            {
                for (int day = 0; day < bound1; day++)
                {
                        if(tmp[week,day].thisMonth) {
                                if(day==0 || day==6 )
                                        mCells[week,day] = new RedCell(tmp[week,day].day, new Rect(Bound), CELL_TEXT_SIZE);
                                else 
                                        mCells[week,day] = new Cell(tmp[week,day].day, new Rect(Bound), CELL_TEXT_SIZE);
                        } else {
                                mCells[week,day] = new GrayCell(tmp[week,day].day, new Rect(Bound), CELL_TEXT_SIZE);
                        }
                                
                        Bound.Offset(CELL_WIDTH, 0); // move to next column 
                                
                        // get today
                        if(tmp[week,day].day==thisDay && tmp[week,day].thisMonth) {
                                mToday = mCells[week,day];
                                mDecoration.SetBounds(mToday.Bounds.Left, mToday.Bounds.Top, mToday.Bounds.Right, mToday.Bounds.Bottom);
                        }
                }
                Bound.Offset(0, CELL_HEIGH); // move to next row and first column
                Bound.Left = CELL_MARGIN_LEFT;
                Bound.Right = CELL_MARGIN_LEFT+CELL_WIDTH;
            }
        }
Exemplo n.º 8
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        bool hell = false;

        //collision with ff
        FerrofluidScript goo          = collision.gameObject.GetComponent <FerrofluidScript> ();
        HealthScript     playerHealth = GetComponent <HealthScript> ();
        FloorScript      floor        = collision.gameObject.GetComponent <FloorScript> ();
        PopUpScript      popUp        = collision.gameObject.GetComponent <PopUpScript> ();
        BossFight        boss         = collision.gameObject.GetComponent <BossFight> ();
        ShieldScript     shield       = collision.gameObject.GetComponent <ShieldScript> ();
        ShieldNumber     shieldnumber = collision.gameObject.GetComponent <ShieldNumber> ();
        FfScript         ffBottle     = collision.gameObject.GetComponent <FfScript> ();
        WingsCounter     wings        = collision.gameObject.GetComponent <WingsCounter> ();
        RobotArm         robot        = GetComponent <RobotArm> ();
        OrangeCell       orangeCell   = collision.gameObject.GetComponent <OrangeCell>();
        RedCell          redCell      = collision.gameObject.GetComponent <RedCell>();
        BlueCell         blueCell     = collision.gameObject.GetComponent <BlueCell>();
        MetalCell        metalCell    = collision.gameObject.GetComponent <MetalCell>();
        MazePlatform     maze         = collision.gameObject.GetComponent <MazePlatform>();


        //BridgePlatformScript bridge = GetComponent<BridgePlatformScript> ();

        if (collision.gameObject.tag == "orange")
        {
//			damagePlayer = true;
//			Debug.Log("shield not hit");
//			if(playerHealth != null)
//				playerHealth.Damage(orangeCell.damage,respawnPosX,respawnPosY,false);

            if (shieldGO.activeSelf == true)
            {
                damagePlayer = false;
                shieldHits--;
                metalCell.hitByShield = true;
                Debug.Log("shield hit");
                //orangeCell = null;
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, true);
                }
            }
            else
            {
                damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, false);
                }
            }
        }

        if (collision.gameObject.tag == "red")
        {
            damagePlayer = true;
            Debug.Log("shield not hit");
            if (playerHealth != null)
            {
                playerHealth.Damage(redCell.damage, respawnPosX, respawnPosY, false);
            }
        }

        if (collision.gameObject.tag == "blue")
        {
            damagePlayer = true;
            Debug.Log("shield not hit");
            if (playerHealth != null)
            {
                playerHealth.Damage(blueCell.damage, respawnPosX, respawnPosY, false);
            }
        }

        if (collision.gameObject.tag == "metal")
        {
            //			damagePlayer = true;
            //			Debug.Log("shield not hit");
            //			if(playerHealth != null)
            //				playerHealth.Damage(orangeCell.damage,respawnPosX,respawnPosY,false);

            if (shieldGO.activeSelf == true)
            {
                damagePlayer = false;
                shieldHits--;
                metalCell.hitByShield = true;
                Debug.Log("shield hit");
            }
            else
            {
                damagePlayer = true;
                Debug.Log("shield not hit");
                if (playerHealth != null)
                {
                    playerHealth.Damage(orangeCell.damage, respawnPosX, respawnPosY, false);
                }
            }
        }


        if (floor != null)
        {
            damagePlayer = true;
            hell         = true;
        }


        if (hell)
        {
            if (playerHealth != null)
            {
                playerHealth.Damage(floor.damage, respawnPosX, respawnPosY, false);
            }
        }
        if (collision.gameObject.name == "Checkpoint1")
        {
            CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>();
            respawnPosX = checkpoint.posX;
            respawnPosY = checkpoint.posY;
            Destroy(collision.gameObject.GetComponent <Collider2D>());
        }
        if (collision.gameObject.name == "Checkpoint2")
        {
            CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>();
            respawnPosX = checkpoint.posX;
            respawnPosY = checkpoint.posY;
            Destroy(collision.gameObject.GetComponent <Collider2D>());
        }
        if (collision.gameObject.name == "Checkpoint3")
        {
            CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>();
            respawnPosX = checkpoint.posX;
            respawnPosY = checkpoint.posY;
            Destroy(collision.gameObject.GetComponent <Collider2D>());
        }
        if (collision.gameObject.name == "Checkpoint4")
        {
            CheckpointScript checkpoint = collision.gameObject.GetComponent <CheckpointScript>();
            respawnPosX = checkpoint.posX;
            respawnPosY = checkpoint.posY;
            Destroy(collision.gameObject.GetComponent <Collider2D>());
        }

//		if (collision.gameObject.name == "atomo") {
//			popUp.showPopUp = true;
//			popUp.gameObject.GetComponent<Renderer>().enabled = false;
//			Destroy(popUp.gameObject.GetComponent<Collider2D>());
//		}

        if (collision.gameObject.tag == "MovingPlatform")
        {
            this.transform.parent = collision.transform;
        }

//		if (collision.gameObject.tag == "lever"){
//			RobotArm.move = true;
//		}
//
//		if (collision.gameObject.tag == "lever1") {
//			RobotArm.move1 = true;
//		}

        if (collision.gameObject.tag == "Boss")
        {
            boss.gameObject.GetComponent <Renderer>().enabled = true;

            showPopUp = true;
            maxSpeed  = 0;

            if (i == 5)
            {
                maxSpeed = 25;
                Destroy(boss.gameObject);
                boss.gameObject.GetComponent <Renderer>().enabled = false;
            }
        }

        if (collision.gameObject.tag == "Door")
        {
            Application.LoadLevel("Hidrofobia");
        }

        if (wings != null)
        {
            wings.GetComponent <Renderer>().enabled          = false;
            wings.GetComponent <PolygonCollider2D>().enabled = false;
            wingsCounter = 7;
        }

        if (collision.gameObject.tag == "shield")
        {
            ShieldCounterManager.AddShield(shieldnumber.shieldNumber);
            Destroy(shieldnumber.gameObject);
            shieldFlag = true;
            Debug.Log("Shield available");
        }


        if (collision.gameObject.tag == "ffbottle")
        {
            FfCounterManager.AddFF(ffBottle.ffNumber);
            gunFlag = true;
            Destroy(ffBottle.gameObject);
        }

        //platform activator
        if (collision.gameObject.tag == "ActivatePlatform")
        {
            collision.gameObject.GetComponent <Animator>().enabled = true;
        }

        if (collision.gameObject.tag == "Boots")
        {
            collision.gameObject.GetComponent <Renderer>().enabled          = false;
            collision.gameObject.GetComponent <PolygonCollider2D>().enabled = false;
            time = 5;
        }

        if (collision.gameObject.tag == "box")
        {
            bool          founded = false;
            BoxController box     = collision.gameObject.GetComponent <BoxController>();
            box.Founded(true);
            Destroy(collision.gameObject);
        }

        if (collision.gameObject.tag == "Bridge1")
        {
            BridgePlatformScript.bridge1 = true;
        }
        if (collision.gameObject.tag == "Bridge2")
        {
            BridgePlatformScript.bridge2 = true;
        }
        if (collision.gameObject.tag == "Bridge3")
        {
            BridgePlatformScript.bridge3 = true;
        }
        if (collision.gameObject.tag == "Bridge4")
        {
            BridgePlatformScript.bridge4 = true;
        }
        if (collision.gameObject.tag == "Bridge5")
        {
            BridgePlatformScript.bridge5 = true;
        }
        if (collision.gameObject.tag == "Bridge6")
        {
            BridgePlatformScript.bridge6 = true;
        }
        if (collision.gameObject.tag == "Bridge7")
        {
            BridgePlatformScript.bridge7 = true;
        }
        if (collision.gameObject.name == "MetallicFloorFerroFluidMAP 159")
        {
            MazePlatform.ground = true;
            transform.parent    = collision.transform;
        }
    }
        private void InitCells()
        {
            _calendar[,] tmp = new _calendar[6, 7];

            for (int i = 0; i < tmp.GetUpperBound(0); i++)
            {
                int[] n = mHelper.GetDigitsForRow(i);
                for (int d = 0; d < n.Length; d++)
                {
                    if (mHelper.IsWithinCurrentMonth(i, d))
                    {
                        tmp[i, d] = new _calendar(n[d], true);
                    }
                    else
                    {
                        tmp[i, d] = new _calendar(n[d]);
                    }
                }
            }

            DateTime today   = DateTime.Now;
            int      thisDay = 0;

            mToday = null;
            if (mHelper.Year == today.Year && mHelper.Month == today.Month)
            {
                thisDay = today.Day;
            }

            // build cells
            Rect Bound = new Rect(CELL_MARGIN_LEFT, CELL_MARGIN_TOP, CELL_WIDTH + CELL_MARGIN_LEFT, CELL_HEIGH + CELL_MARGIN_TOP);

            int bound0 = mCells.GetUpperBound(0);
            int bound1 = mCells.GetUpperBound(1);

            for (int week = 0; week < bound0; week++)
            {
                for (int day = 0; day < bound1; day++)
                {
                    if (tmp[week, day].thisMonth)
                    {
                        if (day == 0 || day == 6)
                        {
                            mCells[week, day] = new RedCell(tmp[week, day].day, new Rect(Bound), CELL_TEXT_SIZE);
                        }
                        else
                        {
                            mCells[week, day] = new Cell(tmp[week, day].day, new Rect(Bound), CELL_TEXT_SIZE);
                        }
                    }
                    else
                    {
                        mCells[week, day] = new GrayCell(tmp[week, day].day, new Rect(Bound), CELL_TEXT_SIZE);
                    }

                    Bound.Offset(CELL_WIDTH, 0);     // move to next column

                    // get today
                    if (tmp[week, day].day == thisDay && tmp[week, day].thisMonth)
                    {
                        mToday = mCells[week, day];
                        mDecoration.SetBounds(mToday.Bounds.Left, mToday.Bounds.Top, mToday.Bounds.Right, mToday.Bounds.Bottom);
                    }
                }
                Bound.Offset(0, CELL_HEIGH); // move to next row and first column
                Bound.Left  = CELL_MARGIN_LEFT;
                Bound.Right = CELL_MARGIN_LEFT + CELL_WIDTH;
            }
        }