Пример #1
0
        public async Task <IActionResult> Edit(double id, [Bind("BurialId,BioId,HairTaken,SoftTissueTaken,BoneTaken,ToothTaken,TextileTaken,DescriptionOfTaken,ArtifactFound,EstimateAge,EstimateLivingStature,ToothAttrition,ToothEruption,PathologyAnomalies,EpiphysealUnion,Burialsampletaken")] Biology biology)
        {
            if (id != biology.BioId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(biology);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BiologyExists(biology.BioId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("BurialDetails", "Home", new { burialId = biology.BurialId }));
            }
            ViewData["BurialId"] = new SelectList(_context.MainTbl, "BurialId", "BurialId", biology.BurialId);
            return(View(biology));
        }
Пример #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        Biology Biology = (Biology)target;

        if (GUI.changed)
        {
            Biology.LoadDB();
        }
        if (GUILayout.Button("載入資訊"))
        {
            Biology.LoadDB();
        }

        /*
         *      if (GUI.changed)
         *      {
         *          Biology.LoadDB();
         *      }
         *      if (GUILayout.Button("移除生物"))
         *      {
         *          Selection.activeGameObject = GameObject.Find("生物清單").gameObject;
         *          Biology.DestroyGameObject(); //fixme:在unity 5.6 這樣的操作會造成錯誤訊息,如果2017不會的話就把這行備註更正吧
         *      }
         *
         *      if (GUILayout.Button("返回清單"))
         *      {
         *          Selection.activeGameObject = GameObject.Find("生物清單").gameObject;
         *      }
         */
    }
        //!!!very similar to other code
        public static Dictionary <Pair <NEC, Hla>, bool> ReadTable(HlaFactory hlaFactory, string fileName, bool dedup)
        {
            Dictionary <Pair <NEC, Hla>, bool> table = new Dictionary <Pair <NEC, Hla>, bool>();

            foreach (Dictionary <string, string> row in SpecialFunctions.TabFileTable(fileName, "N\tepitope\tC\thla\tlabel", false))
            {
                string n       = row["N"];
                string epitope = row["epitope"];
                SpecialFunctions.CheckCondition(Biology.GetInstance().LegalPeptide(epitope), string.Format("Peptide, '{0}', contains illegal char.", epitope));
                string c           = row["C"];
                NEC    nec         = NEC.GetInstance(n, epitope, c);
                Hla    hla         = hlaFactory.GetGroundInstance(row["hla"]);
                string labelString = row["label"];
                SpecialFunctions.CheckCondition(labelString == "0" || labelString == "1", "Expect label to be '0' or '1'");
                Pair <NEC, Hla> pair        = new Pair <NEC, Hla>(nec, hla);
                bool            labelAsBool = (labelString == "1");
                if (dedup && table.ContainsKey(pair))
                {
                    SpecialFunctions.CheckCondition(table[pair] == labelAsBool, "The example " + pair.ToString() + " appears with contradictory labels.");
                    continue;
                }
                table.Add(pair, labelAsBool);
            }
            return(table);
        }
Пример #4
0
 public bool BiomeHasFood(BiomeMemory _biome, Biology _bio, float dailyFoodConsumption, float dailyWaterConsumption)
 {
     if (_bio.dietType == Biology.DietType.Carnivore)
     {
         if (dailyFoodConsumption < (_biome.meatMass - _biome.meatConsumptionMass) && dailyWaterConsumption < (_biome.waterMass - _biome.waterConsumption))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         if (dailyFoodConsumption < (_biome.foliageMass - _biome.foliageConsumptionMass) && dailyWaterConsumption < (_biome.waterMass - _biome.waterConsumption))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
 }
Пример #5
0
    private void selectTarget()
    {
        int target = Random.Range(0, 2);

        // target 可以设置为固定 这样攻击目标将固定
        if (ourList.Contains(rpList [round]))
        {
            if (target == 0)
            {
                hurt = otherList [0].hp > 0 ? otherList [0] : otherList [1];
            }
            else
            {
                hurt = otherList [1].hp > 0 ? otherList [1] : otherList [0];
            }
        }
        else
        {
            if (target == 0)
            {
                hurt = ourList [0].hp > 0 ? ourList [0] : ourList [1];
            }
            else
            {
                hurt = ourList [1].hp > 0 ? ourList [1] : ourList [0];
            }
        }
    }
Пример #6
0
 void Start()
 {
     Biology = GetComponent <Biology>();
     Lv      = Biology.Lv;
     Type    = Biology.Type;
     LoadDB();
     Rest();
 }
Пример #7
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        Biology biology = animator.GetComponent <Biology>();

        biology.UpdateAnimationState(AnimationState);
        animator.SetBool("IsPunching", IsPunching);
        animator.SetBool("IsPunchNext", IsPunchNext);
    }
Пример #8
0
    internal void _SelectBiologysRemove(Biology b)
    {
        Renderer r = b.BiologyLook.SkinnedMeshRenderer;

        SelectBiologysRenderer.Remove(r);
        _SelectBiologys.Remove(b);
        HighlightsFXUpdate();
    }
Пример #9
0
    private void _SelectBiologysAdd(Biology b)
    {
        Renderer r = b.BiologyLook.SkinnedMeshRenderer;

        SelectBiologysRenderer.Add(r);
        _SelectBiologys.Add(b);
        HighlightsFXUpdate();
    }
Пример #10
0
 private bool IsBiologyDead(Biology biology)
 {
     if (biology.BiologyAttr.Hp <= 0)
     {
         return(true);
     }
     return(false);
 }
Пример #11
0
    private void OnTriggerExit(Collider other)
    {
        float      massAmount = 0;
        IHaveMass  _mass      = other.GetComponent <IHaveMass>();
        IHaveWater _water     = other.GetComponent <IHaveWater>();

        if (_mass != null)
        {
            massAmount = _mass.Mass;
        }
        IAmPlant _plant = other.GetComponent <IAmPlant>();

        if (_plant != null)
        {
            if (_mass != null)
            {
                massAmount = _mass.Mass;
            }
            if (_plant.PlantType == "Foliage")
            {
                _memory.foliageMass -= massAmount;
            }
            else
            {
                _memory.fruitMass -= massAmount;
            }
        }
        else if (other.GetComponent <IAmTree>() != null)
        {
            _memory.treeCount -= 1;
        }
        else if (other.GetComponent <IAmCreature>() != null)
        {
            Biology _bio = other.GetComponent <Biology>();
            if (_bio != null)
            {
                if (_bio.dietType == Biology.DietType.Carnivore)
                {
                    _memory.meatConsumptionMass -= other.GetComponent <IHaveFood>().MaxFood;
                    _memory.carnivoreList.Remove(other.gameObject);
                    _memory.carnivoreCount -= 1;
                    _memory.meatMass       -= massAmount;
                }
                else if (_bio.dietType == Biology.DietType.Herbivore)
                {
                    _memory.foliageConsumptionMass -= other.GetComponent <IHaveFood>().MaxFood;
                    _memory.herbivoreList.Remove(other.gameObject);
                    _memory.herbivoreCount -= 1;
                    _memory.meatMass       -= massAmount;
                }
                _memory.waterConsumption -= _water.MaxWater;
            }
        }
        else if (other.GetComponent <IAmWater>() != null)
        {
            _memory.waterMass -= massAmount;
        }
    }
Пример #12
0
    private bool Foe_Any(float n)
    {
        if (BiologyAI.Visible_Foe_Biologys == null)
        {
            return(false);
        }

        Target = BiologyAI.Visible_Foe_Biologys[0];
        return(true);
    }
Пример #13
0
 private void Awake()
 {
     _bio     = GetComponent <Biology>();
     _harvest = GetComponent <IHarvest>();
     _attack  = GetComponent <IAttack>();
     _memory  = GetComponent <CreatureMemory>();
     _nav     = GetComponent <NPCNavigation>();
     _reach   = GetComponent <IHaveReach>();
     _drink   = GetComponent <CreatureDrink>();
 }
Пример #14
0
 private void SetSingleBiologySelected(Biology biology)
 {
     if (SelectBiologys == null)
     {
         SelectBiologys = new List <Biology>();
     }
     SelectBiologysHideCircleLine();
     SelectBiologysClear();
     SelectBiologys.Add(biology);
     biology.CircleLine.Show();
 }
Пример #15
0
 public BiologyMovement(Biology biology)
 {
     Biology          = biology;
     WalkStep         = biology.BiologyLook.WalkStep;
     BiologyTransfrom = biology.transform;
     NavMeshAgent     = biology.GetComponent <UnityEngine.AI.NavMeshAgent>();
     NavMeshAgent.stoppingDistance = Closest;
     NavMeshAgent.speed            = Biology.Speed;
     _AvoidancePriority            = biology.Type == uFantasy.Enum.BiologyType.Player ? 50 : 99;
     Stop();
 }
Пример #16
0
        public async Task <IActionResult> Create([Bind("BurialId,BioId,HairTaken,SoftTissueTaken,BoneTaken,ToothTaken,TextileTaken,DescriptionOfTaken,ArtifactFound,EstimateAge,EstimateLivingStature,ToothAttrition,ToothEruption,PathologyAnomalies,EpiphysealUnion,Burialsampletaken")] Biology biology)
        {
            if (ModelState.IsValid)
            {
                _context.Add(biology);
                await _context.SaveChangesAsync();

                return(RedirectToAction("BurialDetails", "Home", new { burialId = biology.BurialId }));
            }
            ViewData["BurialId"] = new SelectList(_context.MainTbl, "BurialId", "BurialId", biology.BurialId);
            return(View(biology));
        }
Пример #17
0
    private Vector3[] GetSelectBiologysToCenters()
    {
        Vector3 center = GetSelectBiologysCenter();

        Vector3[] BiologysToCenters = new Vector3[SelectBiologys.Count];
        for (int i = 0; i < SelectBiologys.Count; i++)
        {
            Biology b = SelectBiologys[i];
            BiologysToCenters[i] = b.transform.position - center;
        }
        return(BiologysToCenters);
    }
        //!!!very similar to other code
        public static Dictionary <string, int> ReadTable(string fileName)
        {
            Dictionary <string, int> table = new Dictionary <string, int>();

            foreach (Dictionary <string, string> row in SpecialFunctions.TabFileTable(fileName, "epitope\tdifferenceCount\tid\tstartAABase1", false))
            {
                string epitope = row["epitope"];
                SpecialFunctions.CheckCondition(Biology.GetInstance().LegalPeptide(epitope), string.Format("Peptide, '{0}', contains illegal char.", epitope));
                int differenceCount = int.Parse(row["differenceCount"]);
                MaxMaxMismatches = Math.Max(MaxMaxMismatches, differenceCount);
                table.Add(epitope, differenceCount);
            }
            return(table);
        }
Пример #19
0
    public BiologyAI(Biology Parent, string AiNumber)
    {
        //如果無此資料
        if (AiNumber == "" || GameDB.Instance.BiologyAi.ContainsKey(AiNumber) == false)
        {
            return;
        }

        this.AiNumber = AiNumber;
        this.Parent   = Parent;
        ConditionList = GetConditionList();
        ActionList    = GetActionList();
        Vision        = GetVision();
    }
Пример #20
0
    private void OnTriggerExit(Collider other)
    {
        if (other.GetComponent <Biology>() == null)
        {
            return;
        }
        if (other.GetComponent <Biology>().Type != uFantasy.Enum.BiologyType.Player)
        {
            return;
        }
        Biology b = other.GetComponent <Biology>();

        _SelectBiologysRemove(b);
    }
Пример #21
0
 private bool n_HP_Less_Point(List <Biology> biologys, float n)
 {
     for (int i = 0; i < biologys.Count; i++)
     {
         Biology p = biologys[i];
         if ((float)p.BiologyAttr.Hp >= n)
         {
             continue;
         }
         Target = p;
         return(true);
     }
     return(false);
 }
Пример #22
0
 private bool Foe_HP_Full(float n)
 {
     for (int i = 0; i < BiologyAI.Visible_Foe_Biologys.Count; i++)
     {
         Biology p = BiologyAI.Visible_Foe_Biologys[i];
         if ((float)p.BiologyAttr.Hp < (float)p.BiologyAttr.HpMax)
         {
             continue;
         }
         Target = p;
         return(true);
     }
     return(false);
 }
Пример #23
0
 private bool Foe_Targeting_Self(float arg)
 {
     for (int i = 0; i < BiologyAI.Visible_Foe_Biologys.Count; i++)
     {
         Biology p = BiologyAI.Visible_Foe_Biologys[i];
         if (p.Target != BiologyAI.Parent)
         {
             continue;
         }
         Target = p;
         return(true);
     }
     return(false);
 }
Пример #24
0
        public IHttpActionResult DeleteBiology(int id)
        {
            Biology biology = db.Biology.Find(id);

            if (biology == null)
            {
                return(NotFound());
            }

            db.Biology.Remove(biology);
            db.SaveChanges();

            return(Ok(biology));
        }
Пример #25
0
 // 当前该谁攻击 返回序号
 public int selectAttacker()
 {
     // 决定当次攻击由谁开始
     round++;
     if (round >= rpList.Count)
     {
         round = 0;
         // 一回合过后重新根据速度排列(可能技能加速度)
         rpList = sort(rpList);
     }
     // 速度最快的为攻击者 在每次回合完之前该值不会变动
     attacker = rpList[round];
     return(round);
 }
Пример #26
0
    private Vector3 GetSelectBiologysCenter()
    {
        float x = 0, y = 0, z = 0;
        float count = SelectBiologys.Count;

        for (int i = 0; i < SelectBiologys.Count; i++)
        {
            Biology b = SelectBiologys[i];
            x += b.transform.position.x;
            y += b.transform.position.y;
            z += b.transform.position.z;
        }
        x /= count; y /= count; z /= count;
        return(new Vector3(x, y, z));
    }
Пример #27
0
    public void Condition(BiologyAI Ai)
    {
        BiologyAI = Ai;


        for (int i = 0; i < Ai.ConditionList.Count; i++)
        {
            //清空上一個目標與上一個行為
            BiologyAI.Parent.Target = null;
            Target     = null;
            ActionName = null;

            //如果我已經死則清空目標並跳出
            if (BiologyAI.Parent.BiologyAttr.Hp <= 0)
            {
                BiologyAI.Parent.Target = null; return;
            }

            //如果資料庫無此策略跳下一個
            if (Conditions.ContainsKey(Ai.ConditionList[i]) == false)
            {
                continue;
            }

            //如果此策略找不到目標則跳下一個
            //在這裡決定 Target 是誰
            Func <float, bool> f  = Conditions[Ai.ConditionList[i]].Func;
            float cp              = Conditions[Ai.ConditionList[i]].p1;
            bool  ConditionResult = f(cp);
            if (ConditionResult == false)
            {
                continue;
            }

            //取得該策略對應的行為
            ConditionName = Ai.ConditionList[i];
            ActionName    = Ai.ActionList[i];

            //檢查該行為是否可以執行
            if (BiologyAI_Action.Instance.CheckAction(this, Target) == false)
            {
                continue;
            }

            //持續思考(重頭)
            return;
        }
    }
Пример #28
0
 // 战斗序列排序 根据speed
 private List <Biology> sort(List <Biology> list)
 {
     for (int i = 0; i < list.Count - 1; i++)
     {
         for (int j = 0; j < list.Count - 1 - j; j++)
         {
             if (list[i].speed > list[j].speed)
             {
                 Biology temp = list [j];
                 list [j] = list [i];
                 list [i] = temp;
             }
         }
     }
     return(list);
 }
Пример #29
0
 private bool Foe_Targeting_Ally(float arg)
 {
     for (int i = 0; i < BiologyAI.Visible_Foe_Biologys.Count; i++)
     {
         Biology p = BiologyAI.Visible_Foe_Biologys[i];
         for (int j = 0; j < BiologyAI.Visible_Ally_Biologys.Count; j++)
         {
             if (p.Target != BiologyAI.Visible_Ally_Biologys[j])
             {
                 continue;
             }
             Target = p;
             return(true);
         }
     }
     return(false);
 }
Пример #30
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        Biology = (Biology)target;

        GUILayout.BeginVertical("box");
        DrawSelectedBiologyLayout();
        if (GUILayout.Button("移除生物"))
        {
            Selection.activeGameObject.GetComponent <Biology>().DestroyGameObject();
        }
        GUILayout.EndVertical();

        if (GUI.changed)
        {
            Selection.activeGameObject.GetComponent <Biology>().BiologyNum = Biology.BiologyNum;
            Biology.LoadDB();
        }
    }