private void InitComponent(EnemyData data, EnemyType type, Sprite sprite, ITrajectoryData trajectoryData)
    {
        //更新飞机图片
        Renderer = gameObject.AddOrGet <RenderComponent>();
        Renderer.Init();
        Renderer.SetSprite(sprite);
        //路径初始化
        _path = new PathMgr();
        _path.Init(transform, data, trajectoryData);

        gameObject.AddOrGet <CameraMove>().enabled = _path.NeedMoveWithCamera();
        gameObject.AddOrGet <AutoDespawnComponent>();
        gameObject.AddOrGet <EnemyTypeComponent>().Init(type);
        var lifeC = gameObject.AddOrGet <LifeComponent>();

        lifeC.Init(data.life);
        gameObject.AddOrGet <EnemyBehaviour>().Init(data);
        _moveComponent = gameObject.AddOrGet <MoveComponent>();
        _moveComponent.Init((float)data.speed);
        gameObject.AddOrGet <ColliderComponent>();
        gameObject.AddOrGet <PlaneCollideMsgComponent>();
        var bulletMgr = transform.Find("BulletRoot").AddOrGet <EnemyBulletMgr>();

        bulletMgr.Init(data);

        if (_lifeView == null)
        {
            var lifeGo = LoadMgr.Single.LoadPrefabAndInstantiate(Paths.PREFAB_ENEMY_LIFE, transform);
            _lifeView = lifeGo.AddComponent <EnemyLifeView>();
        }

        _lifeView.Init();
    }
Exemple #2
0
 protected override void InitComponent()
 {
     gameObject.AddOrGet <CameraMove>();
     _move = gameObject.AddOrGet <MoveComponent>();
     _move.Init(_speed);
     gameObject.AddOrGet <AutoDespawnComponent>();
     gameObject.AddOrGet <ColliderComponent>();
     gameObject.AddOrGet <ItemCollideMsgComponent>().Init(CollidePlayer);
 }
Exemple #3
0
    void addMoveComponent(Enemy enemy, bool wave, int damage)
    {
        MoveComponent mc = null;

        mc = this.projectileInstance.AddComponent <MoveComponent>();

        mc.Init(this.projectileTarget, GameElementConstants.bulletVelocity);

        mc.selfDestroy = true;

        mc.TargetReachedEvent += () => enemy.ApplyDamage(amount: damage);
    }
Exemple #4
0
    // Use this for initialization
    private void Start()
    {
        _speed = 0;
        var reader = ReaderMgr.Single.GetReader(Paths.CONFIG_Game_CONFIG);

        reader["cameraSpeed"].Get <float>(value =>
        {
            _speed = value;
            _move  = gameObject.AddComponent <MoveComponent>();
            _move.Init(_speed);
        });
    }
    public void Init(TileInteraction originTile, cCards characterType)
    {
        MoveComponent.Init(originTile.GridTile.Location.X, originTile.GridTile.Location.Y);

        switch (characterType)
        {
        case cCards.Beetle:
            gameObject.AddComponent <BeetleBehaviour>();
            break;

        case cCards.RedBeetle:
            gameObject.AddComponent <RedBeetleBehaviour>();
            break;
        }
    }
Exemple #6
0
    public void Init(PawnStructConfig Config)
    {
        if (_moveComp)
        {
            _moveComp.Init(Config.MoveConfig);
        }

        if (_bodyComp)
        {
            _bodyComp.Init(Config.BodyConfig);
        }

        if (_shootComp)
        {
            _shootComp.Init(Config.ShootConfig);
        }
    }
Exemple #7
0
    public void UpdateFun()
    {
        if (_move == null)
        {
            return;
        }
        if (_speed < _speedLimit)
        {
            _speed = _speedLimit;
        }
        else
        {
            _speed -= _slowSpeed * Time.deltaTime;
        }

        _move.Init(_speed);
        _move.Move(_axis);
    }
Exemple #8
0
    public void Init(IBulletModel model, ITrajectory trajectory, Vector3 pos)
    {
        if (_renderer == null)
        {
            _renderer = GetComponent <SpriteRenderer>();
        }
        _model           = model;
        _renderer.sprite = model.Sprite();
        _trajectory      = trajectory;
        SetPos(pos);

        if (_effectMgr == null)
        {
            _effectMgr = gameObject.AddComponent <BulletEffectMgr>();
        }
        _effectMgr.Init(model.Type);

        _model.GetBulletSpeed(value =>
        {
            _move = gameObject.AddOrGet <MoveComponent>();
            _move.Init(value);
        });
    }
Exemple #9
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);
        }
    }