示例#1
0
    public override void Execute(List <BasicEntity> entities)
    {
        foreach (var entity in entities)
        {
            KnockComponent   knock = entity.gameObject.GetComponent <KnockComponent>();
            AbilityComponent ab    = entity.GetComponent <AbilityComponent>();
            InputComponent   input = entity.GetComponent <InputComponent>();
            StateComponent   ap    = entity.GetComponent <StateComponent>();

            int i = AiToInput.GetAbilityCount(entity, M_LinkedType);
            if (i >= ab.m_temporaryAbility.Count || i != input.currentKey)
            {
                knock.m_area = null;
                continue;
            }
            //获取影响范围
            if (knock.m_area == null)
            {
                knock.m_area = FindPath.GetArea(knock.GetComponent <BlockInfoComponent>().m_logicPosition, knock.m_ridus);
            }
            UISimple ui = GameObject.Find("UI").GetComponent <UISimple>();
            ui.ShowUI(knock.m_area, 3);
            VoxelBlocks        map   = GameObject.Find("Voxel Map").GetComponent <VoxelBlocks>();
            List <BasicEntity> enemy = new List <BasicEntity>();


            //获取影响范围内的敌人
            foreach (var pos in knock.m_area)
            {
                var e = map.GetBlockByLogicPos(pos).entity;
                if (e != null)
                {
                    if (e.GetComponent <BlockInfoComponent>().m_blockType == BlockType.Enemy)
                    {
                        enemy.Add(e);
                    }
                }
            }
            //UI显示范围与敌人
            if (input.leftButtonDown)
            {
                foreach (var e in enemy)
                {
                    Debug.Log(e.name);
                    e.GetComponent <MonitorComponent>().m_voice.Add(entity.GetComponent <BlockInfoComponent>().m_logicPosition);
                }
                ui.ShowUI(null, 3);
                StateComponent state = entity.GetComponent <StateComponent>();
                state.m_actionPoint -= 1;
                state.AnimationStart();

                state.Invoke("AnimationEnd", 1);
            }
        }
    }
示例#2
0
    //添加某一类型的组件
    public BasicComponent AddComponent(ComponentType type)
    {
        if (ExistSpecialComponent(type))
        {
            //Debug.Log("Exist same component Type" + type);
            return(GetSpecicalComponent(type));
        }
        //Debug.Log ("Add component" + type + " in " + gameObject);

        PropertyComponent property = GetComponent <PropertyComponent> ();

        switch (type)
        {
        case ComponentType.Property:
            PropertyComponent propertyComp = gameObject.AddComponent <PropertyComponent> ();
            propertyComp.Init(ComponentType.Property, this);
            m_components.Add(propertyComp);
            return(propertyComp);

        case ComponentType.Dead:
            DeadComponent deadComp = gameObject.AddComponent <DeadComponent> ();
            deadComp.Init(ComponentType.Dead, this);
            deadComp.hp = property.HP;
            m_components.Add(deadComp);

            return(deadComp);

        case ComponentType.State:
            StateComponent stateComp = gameObject.AddComponent <StateComponent> ();
            stateComp.Init(ComponentType.State, this);
            m_components.Add(stateComp);
            stateComp.m_actionPoint = property.AP;
            return(stateComp);

        case ComponentType.Ability:
            AbilityComponent abilityComp = gameObject.AddComponent <AbilityComponent> ();
            abilityComp.Init(ComponentType.Ability, this);
            m_components.Add(abilityComp);
            return(abilityComp);

        case ComponentType.Hide:
            HideComponent hideComp = gameObject.AddComponent <HideComponent> ();
            hideComp.Init(ComponentType.Hide, this);
            m_components.Add(hideComp);
            return(hideComp);

        case ComponentType.Move:
            MoveComponent moveComp = gameObject.AddComponent <MoveComponent> ();
            moveComp.Init(ComponentType.Move, this);
            m_components.Add(moveComp);
            moveComp.moveSpeed = property.moveSpd;
            moveComp.SPD       = property.SPD;
            return(moveComp);

        case ComponentType.Attack:
            AttackComponent attackComp = gameObject.AddComponent <AttackComponent> ();
            attackComp.Init(ComponentType.Attack, this);
            m_components.Add(attackComp);
            attackComp.STR = property.STR;
            return(attackComp);

        case ComponentType.Input:
            InputComponent inputComp = gameObject.AddComponent <InputComponent> ();
            inputComp.Init(ComponentType.Input, this);
            m_components.Add(inputComp);
            return(inputComp);

        case ComponentType.CheerUp:
            CheerUpComponent cheerUpComp = gameObject.AddComponent <CheerUpComponent> ();
            cheerUpComp.Init(ComponentType.CheerUp, this);
            m_components.Add(cheerUpComp);
            return(cheerUpComp);

        case ComponentType.Monitor:
            MonitorComponent monitorComp = gameObject.AddComponent <MonitorComponent> ();
            monitorComp.Init(ComponentType.Monitor, this);
            m_components.Add(monitorComp);
            monitorComp.m_SightArea = property.HRZ;
            return(monitorComp);

        case ComponentType.Knock:
            KnockComponent knockComp = gameObject.AddComponent <KnockComponent> ();
            knockComp.Init(ComponentType.Knock, this);
            m_components.Add(knockComp);
            knockComp.m_ridus = property.HRZ;
            return(knockComp);

        case ComponentType.Item:
            ItemComponent itemComp = gameObject.AddComponent <ItemComponent> ();
            itemComp.Init(ComponentType.Item, this);
            itemComp.item     = property.item;
            itemComp.numLimit = property.itemLimit;
            m_components.Add(itemComp);
            return(itemComp);

        case ComponentType.AI:
            AIComponent aiComp = gameObject.AddComponent <AIComponent> ();
            aiComp.Init(ComponentType.AI, this);
            m_components.Add(aiComp);
            return(aiComp);

        case ComponentType.UI:
            UIComponent uiComp = gameObject.AddComponent <UIComponent>();
            uiComp.Init(ComponentType.UI, this);
            m_components.Add(uiComp);
            return(uiComp);

        default:
            return(null);
        }
    }