Beispiel #1
0
 // Start is called before the first frame update
 void Start()
 {
     testTime = DateTime.Now;
     enemies  = new List <GameObject>();
     reported = false;
     findEnemies("Robot");
     findEnemies("Human");
     nEnemies = enemies.ToArray().Length;
     enemies.Clear();
     human = GameObject.FindGameObjectWithTag("Player").GetComponent <KillCondition>();
 }
Beispiel #2
0
    void OnJudgePassCondition()
    {
        // 判断是否通关

        // Check Point判断
        bool pass = true;

        for (int index = checkPoint; index <= checkPointScores.Count; ++index)
        {
            if (curTotalScore > checkPointScores[index - 1])
            {
                checkPoint += 1;
                gameTime    = 0;
                EventDispatcher.TriggerEvent(GameEventDef.EVNET_ENVIRONMENT_MOVE_SPEED_SCALE);
            }
        }
        if (checkPoint <= checkPointScores.Count)
        {
            pass = false;
        }

        // 击杀数量
        //foreach (KeyValuePair<string, int> element in killTypeCondition)
        //{
        //    if(element.Value > 0)
        //    {
        //        pass = false;
        //        break;
        //    }
        //}
        // 击杀条件
        for (int index = 0; index < killIdList.Count; ++index)
        {
            if (killIdCondition.ContainsKey(killIdList[index]))
            {
                KillCondition element = killIdCondition[killIdList[index]];
                if (element.count > 0)
                {
                    pass = false;
                    break;
                }
            }
        }

        if (!pass)
        {
            return;
        }

        StartCoroutine(OnCloseEndingSuccess());
    }
Beispiel #3
0
    void OnEventMonsterDeath(int MonsterType, int MonsterId)
    {
        //string typeName = "";
        //if (MonsterType == (int)Monster.MonsterType.Normal ||
        //    MonsterType == (int)Monster.MonsterType.Senior)
        //{
        //    typeName = "Monster";
        //}
        //else if (MonsterType == (int)Monster.MonsterType.Boss)
        //{
        //    typeName = "Boss";
        //}
        //else if (MonsterType == (int)Monster.MonsterType.NPC)
        //{
        //    typeName = "NPC";
        //}
        //if (killTypeCondition.ContainsKey(typeName))
        //{
        //    int killCount = killTypeCondition[typeName];
        //    killCount -= 1;
        //    if (killCount < 0)
        //        killCount = 0;
        //    killTypeCondition[typeName] = killCount;
        //}

        if (killIdCondition.ContainsKey(MonsterId))
        {
            KillCondition killCount = killIdCondition[MonsterId];
            if (killCount.type != checkPoint)
            {
                return;
            }
            killCount.count -= 1;
            if (killCount.count < 0)
            {
                killCount.count = 0;
            }
            killIdCondition[MonsterId] = killCount;
        }
    }
 public static T SetKillCondition <T>(this T entity, KillCondition value)
     where T : KillForm
 {
     entity.SetField("killCondition", value);
     return(entity);
 }
Beispiel #5
0
        private static QuestCondition ShowConditionInfo(QuestCondition condition)
        {
            var oldtype = condition.ConditionType;

            condition.ConditionType = (ConditionType)RPGMakerGUI.EnumPopup("Condition Type:", condition.ConditionType);
            if (condition.ConditionType != oldtype)
            {
                //TODO: if no longer interact node tree than delete that node tree

                switch (condition.ConditionType)
                {
                case ConditionType.Kill:
                    condition = new KillCondition();
                    break;

                case ConditionType.Item:
                    condition = new ItemCondition();
                    break;

                case ConditionType.Interact:
                    condition = new InteractCondition();
                    break;

                case ConditionType.Deliver:
                    condition = new DeliverCondition();
                    break;

                case ConditionType.Custom:
                    condition = new CustomCondition();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }

            var killCondition     = condition as KillCondition;
            var itemCondition     = condition as ItemCondition;
            var interactCondition = condition as InteractCondition;
            var deliverCondition  = condition as DeliverCondition;
            var customCondition   = condition as CustomCondition;

            if (killCondition != null)
            {
                if (Rm_RPGHandler.Instance.Combat.NPCsCanFight && Rm_RPGHandler.Instance.Combat.CanAttackNPcs)
                {
                    RPGMakerGUI.Toggle("Is NPC?", ref killCondition.IsNPC);
                }
                else
                {
                    killCondition.IsNPC = false;
                }

                if (killCondition.IsNPC)
                {
                    RPGMakerGUI.PopupID <NonPlayerCharacter>("NPC to Kill:", ref killCondition.CombatantID);
                }
                else
                {
                    RPGMakerGUI.PopupID <CombatCharacter>("Enemy to Kill:", ref killCondition.CombatantID);
                }

                killCondition.NumberToKill = RPGMakerGUI.IntField("Number To Kill:", killCondition.NumberToKill);
            }

            if (itemCondition != null)
            {
                itemCondition.ItemType = (ItemConditionType)RPGMakerGUI.EnumPopup("Required Item Type:", itemCondition.ItemType);

                if (itemCondition.ItemType == ItemConditionType.CraftItem)
                {
                    RPGMakerGUI.PopupID <Item>("CraftItem To Collect:", ref itemCondition.ItemToCollectID, "ID", "Name", "Craft");
                }
                else if (itemCondition.ItemType == ItemConditionType.QuestItem)
                {
                    RPGMakerGUI.PopupID <Item>("Quest Item To Collect:", ref itemCondition.ItemToCollectID, "ID", "Name", "Quest");

                    if (Rm_RPGHandler.Instance.Combat.NPCsCanFight && Rm_RPGHandler.Instance.Combat.CanAttackNPcs)
                    {
                        RPGMakerGUI.Toggle("NPC Drops Items?", ref itemCondition.NPCDropsItem);
                    }
                    else
                    {
                        itemCondition.NPCDropsItem = false;
                    }

                    if (itemCondition.NPCDropsItem)
                    {
                        RPGMakerGUI.PopupID <NonPlayerCharacter>("NPC that Drops Item:", ref itemCondition.CombatantIDThatDropsItem);
                    }
                    else
                    {
                        RPGMakerGUI.PopupID <CombatCharacter>("Enemy that Drops Item:", ref itemCondition.CombatantIDThatDropsItem);
                    }
                }
                else if (itemCondition.ItemType == ItemConditionType.Item)
                {
                    RPGMakerGUI.PopupID <Item>("Item To Collect:", ref itemCondition.ItemToCollectID);
                }

                itemCondition.NumberToObtain = RPGMakerGUI.IntField("Number To Obtain:", itemCondition.NumberToObtain);
            }

            if (interactCondition != null)
            {
                if (RPGMakerGUI.Toggle("Talk to NPC?", ref interactCondition.IsNpc))
                {
                    RPGMakerGUI.PopupID <NonPlayerCharacter>("NPC to talk to:", ref interactCondition.InteractableID);
                }
                else
                {
                    RPGMakerGUI.PopupID <Interactable>("Object to interact with:", ref interactCondition.InteractableID);
                }

                if (GUILayout.Button("Open Interaction Node Tree", "genericButton", GUILayout.MaxHeight(30)))
                {
                    var trees        = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees;
                    var existingTree = trees.FirstOrDefault(t => t.ID == interactCondition.InteractionNodeTreeID);
                    if (existingTree == null)
                    {
                        existingTree = NodeWindow.GetNewTree(NodeTreeType.Dialog);
                        Debug.Log("ExistingTree null? " + existingTree == null);
                        existingTree.ID = interactCondition.ID;

                        Debug.Log(existingTree.ID + ":::" + existingTree.Name);

                        var curSelectedQuest = Rme_Main.Window.CurrentPageIndex == 1 ? selectedQuestChainQuest : selectedQuest;

                        //todo: need unique name
                        existingTree.Name = curSelectedQuest.Name + "Interact";
                        trees.Add(existingTree);
                    }

                    DialogNodeWindow.ShowWindow(interactCondition.ID);
                    interactCondition.InteractionNodeTreeID = existingTree.ID;
                }
            }

            if (deliverCondition != null)
            {
                RPGMakerGUI.PopupID <Item>("Quest Item To Deliver:", ref deliverCondition.ItemToDeliverID, "ID", "Name", "Quest");
                if (RPGMakerGUI.Toggle("Deliver to NPC?", ref deliverCondition.DeliverToNPC))
                {
                    RPGMakerGUI.PopupID <NonPlayerCharacter>("NPC to deliver to:", ref deliverCondition.InteractableToDeliverToID);
                }
                else
                {
                    RPGMakerGUI.PopupID <Interactable>("Object to deliver with:", ref deliverCondition.InteractableToDeliverToID);
                }

                if (GUILayout.Button("Open Interaction On Deliver", "genericButton", GUILayout.MaxHeight(30)))
                {
                    var trees        = Rm_RPGHandler.Instance.Nodes.DialogNodeBank.NodeTrees;
                    var existingTree = trees.FirstOrDefault(t => t.ID == deliverCondition.InteractionNodeTreeID);
                    if (existingTree == null)
                    {
                        existingTree    = NodeWindow.GetNewTree(NodeTreeType.Dialog);
                        existingTree.ID = deliverCondition.ID;
                        //todo: need unique name
                        var curSelectedQuest = Rme_Main.Window.CurrentPageIndex == 1 ? selectedQuestChainQuest : selectedQuest;

                        existingTree.Name = curSelectedQuest.Name + "Interact";
                        trees.Add(existingTree);
                    }

                    DialogNodeWindow.ShowWindow(deliverCondition.ID);
                    deliverCondition.InteractionNodeTreeID = existingTree.ID;
                }
            }

            if (customCondition != null)
            {
                var customVar = customCondition.CustomVariableRequirement;
                RPGMakerGUI.PopupID <Rmh_CustomVariable>("Custom Variable:", ref customVar.VariableID);
                var foundCvar = Rm_RPGHandler.Instance.DefinedVariables.Vars.FirstOrDefault(v => v.ID == customCondition.CustomVariableRequirement.VariableID);
                if (foundCvar != null)
                {
                    switch (foundCvar.VariableType)
                    {
                    case Rmh_CustomVariableType.Float:
                        customVar.FloatValue = RPGMakerGUI.FloatField("Required Value:", customVar.FloatValue);
                        break;

                    case Rmh_CustomVariableType.Int:
                        customVar.IntValue = RPGMakerGUI.IntField("Required Value:", customVar.IntValue);
                        break;

                    case Rmh_CustomVariableType.String:
                        customVar.StringValue = RPGMakerGUI.TextField("Required Value:", customVar.StringValue);
                        break;

                    case Rmh_CustomVariableType.Bool:
                        selectedVarSetterBoolResult = customVar.BoolValue ? 0 : 1;
                        selectedVarSetterBoolResult = EditorGUILayout.Popup("Required Value:",
                                                                            selectedVarSetterBoolResult,
                                                                            new[] { "True", "False" });
                        customVar.BoolValue = selectedVarSetterBoolResult == 0;
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }

            if (condition.ConditionType != ConditionType.Custom)
            {
                RPGMakerGUI.Toggle("Use Custom Tracking Text:", ref condition.UseCustomText);
            }
            else
            {
                condition.UseCustomText = true;
            }

            if (condition.UseCustomText)
            {
                condition.CustomText          = RPGMakerGUI.TextField("Custom Incomplete Text:", condition.CustomText);
                condition.CustomCompletedText = RPGMakerGUI.TextField("Custom Completed Text:", condition.CustomCompletedText);
            }
            GUILayout.Space(5);

            return(condition);
        }