Exemple #1
0
        public void Initialize(LogicUnit owner, ProjectileProto proto, long id, FixVector3 position, LogicUnit target)
        {
            this.id       = id;
            this.type     = LogicUnitType.Projectile;
            this.owner    = owner;
            this.mark     = owner.mark;
            this.position = position;
            this.target   = target;
            targetId      = target.id;

            metaId      = proto.ID;
            modelId     = proto.Projectile_ResouceId;
            hitEffectId = proto.HitEffect_ResourceId;

            speedFactor = ConvertUtils.ToLogicInt(proto.SpeedFactor);

            damage = owner.damage;

            projectileType     = (ProjectileType)proto.ProjectileType;
            startPosition      = position;
            targetPosition     = target.position;
            speed              = (targetPosition - position).normalized * speedFactor;
            transform.position = position.vector3;
            state              = ProjectileState.Flying;
            targetDistance     = 0;
            destination        = target.position;

            // Temp data
            hurtType = AttackPropertyType.PhysicalAttack;

            DebugUtils.Log(DebugUtils.Type.AI_Projectile, "the projectile " + id + "'s target is " + target.id + ", speed = " + position);
        }
Exemple #2
0
        public void BatteryFire(Vector3 rotation, int projectileId)
        {
            SetRotation(rotation, true);
            PlayAnimation(TRIGGER_USINGBATTRY);

            ProjectileProto projectileProto = null;

            if (unitProjectiles.ContainsKey(projectileId))
            {
                projectileProto = unitProjectiles[projectileId];
            }
            else
            {
                projectileProto = DataManager.GetInstance().projectileProtoData.Find(p => p.ID == projectileId);
                unitProjectiles.Add(projectileId, projectileProto);
            }

            if (projectileProto != null)
            {
                int    fireEffectId = projectileProto.FireEffect_ResourceId;
                string bindPoint    = projectileProto.fire_res_bindpoint;

                PlayEffect(fireEffectId, bindPoint);
            }
        }
Exemple #3
0
        public void SpawnProjecile(Vector3 direction, int projectileMetaId, float speedRate)
        {
            SetRotation(direction, true);

            ProjectileProto proto = null;

            if (unitProjectiles.ContainsKey(projectileMetaId))
            {
                proto = unitProjectiles[projectileMetaId];
            }
            else
            {
                proto = DataManager.GetInstance().projectileProtoData.Find(p => p.ID == projectileMetaId);
            }

            if (proto != null)
            {
                PlayAnimation(TRIGGER_ATTACK, speedRate);
                PlayEffect(proto.FireEffect_ResourceId, proto.fire_res_bindpoint, speedRate);
            }
            else
            {
                DebugUtils.Assert(false, string.Format(" Can't find projectile meta id {0} when solder spawn a projectile", projectileMetaId));
            }
        }
Exemple #4
0
        public void Initialize(long id, Vector3 position, Vector3 direction, ProjectileProto proto)
        {
            this.id = id;
            this.gameObject.name    = id.ToString();
            this.transform.position = position;
            this.transform.rotation = Quaternion.LookRotation(direction);
            this.gameObject.SetActive(true);

            if (proto.HitEffect_ResourceId != 0 && hitEffect == null)
            {
                GameObject go = GameResourceLoadManager.GetInstance().LoadAsset <GameObject>(proto.HitEffect_ResourceId);
                hitEffect = GameObject.Instantiate(go);
                hitEffect.SetActive(false);
            }

            SetChildActive(true);
        }
Exemple #5
0
        public void ReleaseSkill(int index, int skillMetaId, Vector3 position)
        {
            SkillProto proto = DataManager.GetInstance().unitSkillsProtoData.Find(p => p.ID == skillMetaId);

            // TODO: Wait new data struct
            int carrierType = proto.CarrierType;

            int    fireEffectId = 0;
            string bindPoint    = string.Empty;

            if (proto.CarrierID <= 0)
            {
                fireEffectId = proto.SkillEffectID;
                bindPoint    = proto.skill_effect_bindpoint;
                PlayEffect(fireEffectId, bindPoint);
            }
            else
            {
                int carrierId = proto.CarrierID;

                // 1 projectile
                if (carrierType == 1)
                {
                    ProjectileProto projectileProto = null;

                    if (unitProjectiles.ContainsKey(carrierId))
                    {
                        projectileProto = unitProjectiles[carrierId];
                    }
                    else
                    {
                        projectileProto = DataManager.GetInstance().projectileProtoData.Find(p => p.ID == carrierId);
                        unitProjectiles.Add(carrierId, projectileProto);
                    }

                    if (projectileProto != null)
                    {
                        fireEffectId = projectileProto.FireEffect_ResourceId;
                        bindPoint    = projectileProto.fire_res_bindpoint;

                        PlayEffect(fireEffectId, bindPoint);
                    }
                }
                else if (carrierType == 2)
                {
                    // trap
                }
                else if (carrierType == 3)
                {
                    SummonProto summonProto = null;

                    if (summonProtos.ContainsKey(carrierId))
                    {
                        summonProto = summonProtos[carrierId];
                    }
                    else
                    {
                        summonProto = DataManager.GetInstance().summonProtoData.Find(p => p.ID == carrierId);
                        summonProtos.Add(carrierId, summonProto);
                    }

                    if (summonProto != null)
                    {
                        // summon
                        fireEffectId = summonProto.Born_effect_id;
                        PlayEffect(fireEffectId, position);
                    }
                }
            }

            if (index == 1)
            {
                PlayAnimation(TRIGGER_SKILL1, 1);
            }
            else if (index == 2)
            {
                PlayAnimation(TRIGGER_SKILL2, 1);
            }
            else
            {
                DebugUtils.Assert(false, "Can't handle this skill index in soldier render, index = " + index);
            }
        }