Exemple #1
0
    public BulletComponent(LogicEntity entity, LogicEntity releaserEntity) : base(entity)
    {
        this._releaserKey = releaserEntity.EntityKey;
        //hostEntity.LogicTran.
        SafeFloat range = releaserEntity.GetComponent <AttrComponent>().GetAttr(Attr.BulletRange);

        this._checkSqrRange = range * range;
    }
    public LogicEntity CreateBullet(LogicEntity releaserEntity)
    {
        AttrComponent attr   = releaserEntity.GetComponent <AttrComponent>();
        LogicEntity   result = CreateEntityByResPath("");

        result.SetLifeTime(attr.GetAttr(Attr.BulletLife));
        result.AddComponent <BulletComponent>(releaserEntity);
        LogicMove moveComp = result.AddComponent <LogicMove>();

        moveComp.AddMove(releaserEntity.LogicTran.forward, attr.GetAttr(Attr.BulletSpeed), attr.GetAttr(Attr.BulletLife), null);
        return(result);
    }
Exemple #3
0
    public bool Run(PlayerBase player)
    {
        MoveStateArgs args = new MoveStateArgs()
        {
            DirX = this.DirX * 0.01f, DirZ = this.DirZ * 0.01f
        };
        LogicEntity entity = player.Entity;

        if (entity == null)
        {
            return(false);
        }
        StateMachine sm = entity.GetComponent <StateMachine>();

        return(sm.TryChangeState(EntityState.Move, args));
    }
        public override bool TickMove(LogicMove lm, int ms)
        {
            LogicEntity targetEntity = EntityManager.Instance.GetEntity(this._targetId);

            if (targetEntity == null)
            {
                this.InvokeCallback(true);
                return(true);
            }
            LogicTransform targetTran = targetEntity.GetComponent <LogicTransform>();
            SafeV3         dir        = targetTran.position - lm.HostEntity.LogicTran.position;

            if (dir.magnitude * 1000 < speed * ms)
            {
                lm.HostEntity.LogicTran.position = targetTran.position;
                this.InvokeCallback(false);
                return(true);
            }
            dir.SetNormalize();

            lm.MoveOneStep(ms * speed * 0.001f * dir);
            return(false);
        }
Exemple #5
0
    private bool TryHit(LogicEntity target)
    {
        EffectReceiver receiver = target.GetComponent <EffectReceiver>();

        if (receiver == null)
        {
            return(false);
        }
        LogicEntity releaser = EntityManager.Instance.GetEntity(this._releaserKey);

        if (releaser == null)
        {
            return(true);
        }
        AttrComponent attr = releaser.GetComponent <AttrComponent>();

        EffectData data = new EffectData();

        data.OpEntityKey = this._releaserKey;
        data.ChagneAttr  = new AttrPair[] { new AttrPair(Attr.Hp, attr.GetAttr(Attr.Attack)) };
        receiver.ReciveEffect(data);
        return(true);
    }