Exemplo n.º 1
0
    void BossFight()
    {
        BossEntity be = boss.GetComponent <BossEntity>();

        be.AddBoxFight();
        //bottomRow = boxManager.GetBottomNullRow();
    }
    protected virtual void Awake()
    {
        agent = GetComponent <NavMeshAgent>();
        boss  = GetComponent <BossEntity>() != null?GetComponent <BossEntity>() : GetComponent <SasserAddEntity>();

        float baseHP = boss.baseHP;

        for (int i = 0; i < bossPhases.Length; i++)
        {
            if (bossPhases[i].hpToChange >= baseHP || bossPhases[i].hpToChange < 0)
            {
                Debug.LogError("Error with HP logic in the Boss's pattern. Phase index: " + i);
            }

            for (int j = bossPhases[i].patterns.Length - 1; j >= 0; j--)
            {
                if (bossPhases[i].patterns[j].duration < 0)
                {
                    Debug.LogError("Error with Duration logic in the Boss's pattern. Phase index: " + i + ", Pattern:" + j);
                }
            }
        }

        currentPatternDuration = bossPhases[currentPhase].patterns[currentPattern].duration;
    }
 public BossEntity GetOne(int id)
 {
     using (SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["API"].ConnectionString))
     {
         using (SqlCommand cmd = c.CreateCommand())
         {
             cmd.CommandText = "SELECT * FROM Bosses WHERE Id = @Id AND Active = 1";
             cmd.Parameters.AddWithValue("Id", id);
             c.Open();
             using (SqlDataReader Tab = cmd.ExecuteReader())
             {
                 if (Tab.Read())
                 {
                     BossEntity S = new BossEntity()
                     {
                         Id     = (int)Tab["Id"],
                         NameEN = Tab["NameEN"].ToString(),
                         NameFR = Tab["NameFR"].ToString(),
                         Active = (int)Tab["Active"]
                     };
                     return(S);
                 }
                 else
                 {
                     return(null);
                 }
             }
         }
     }
 }
Exemplo n.º 4
0
        public async Task <IActionResult> SaveBoss([FromBody] BossData request)
        {
            var nameClaim = CurrentUserName;

            if (nameClaim == null)
            {
                return(Unauthorized());
            }

            if (!Guid.TryParse(request.Id, out var guid))
            {
                guid = Guid.Empty;
            }
            var boss = await _dataContext.Bosses.FirstOrDefaultAsync(entity => entity.Identifier == guid).ConfigureAwait(false);

            if (boss != null)
            {
                if (boss.UserName != nameClaim)
                {
                    return(Unauthorized());
                }
                boss.Data      = request.Data;
                boss.IsPrivate = request.IsPrivate;
            }
            else
            {
                boss = new BossEntity()
                {
                    Identifier = Guid.NewGuid(),
                    Name       = request.Name,
                    UserName   = request.UserName,
                    IsPrivate  = request.IsPrivate,
                    Data       = request.Data,
                    Reference  = request.Reference,
                    CreateDate = DateTimeOffset.UtcNow,
                    Game       = request.Game
                };
                await _dataContext.Bosses.AddAsync(boss);
            }
            boss.ModifiedDate = DateTimeOffset.UtcNow;

            await _dataContext.SaveChangesAsync().ConfigureAwait(false);

            return(Json(new BossData()
            {
                Id = boss.Identifier.ToString("N"),
                Name = boss.Name,
                UserName = boss.UserName,
                Data = "",
                IsPrivate = boss.IsPrivate,
                Reference = boss.Reference.GetValueOrDefault(),
                CreateDate = boss.CreateDate.GetValueOrDefault(),
                ModifiedDate = boss.ModifiedDate.GetValueOrDefault(),
                Game = boss.Game
            }));
        }
Exemplo n.º 5
0
    void OnTriggerStay2D(Collider2D col)
    {
        if (damaged)
        {
            return;
        }
        BossEntity boss = col.GetComponentInParent <BossEntity> ();

        if (boss != null)
        {
            boss.Damage(10, 1, .1f, 0f);
            damaged = true;
        }
    }
 public void Create(BossEntity T)
 {
     using (SqlConnection c = new SqlConnection(ConfigurationManager.ConnectionStrings["API"].ConnectionString))
     {
         using (SqlCommand cmd = c.CreateCommand())
         {
             if (T != null && T.NameFR != null && T.NameEN != null)
             {
                 cmd.CommandText = "SP_AddBoss";
                 cmd.CommandType = CommandType.StoredProcedure;
                 SqlParameter NameEN = new SqlParameter("NameEN", T.NameEN);
                 SqlParameter NameFR = new SqlParameter("NameFR", T.NameFR);
                 cmd.Parameters.Add(NameFR);
                 cmd.Parameters.Add(NameEN);
                 c.Open();
                 cmd.ExecuteNonQuery();
             }
         }
     }
 }