Пример #1
0
    public List <Record> GetPredictedCluster(Vector3 pos, Vector3 rot, HashSet <Record[]> origin_clusters, List <Cluster> clusterDes)
    {
        var exchangeAxis = new ExchangeAxis();

        Record[] predicted_cluster = null;
        double   maxValue          = -100;

        Debug.Log("现在朝向" + rot);
        Coeffecient     getCoefficient = new Coeffecient();
        int             count          = 0;
        List <Record[]> clusters       = origin_clusters.ToList();

        foreach (var cluster in clusters)
        {
            //数据块的距离(暂时按照cluster0计算)
            //Vector3 clusterCenterPos = exchangeAxis.ModelIndex_to_unityPos((float)cluster[0].posX, (float)cluster[0].posY, (float)cluster[0].posZ);
            Vector3 centerPos        = GetCenterPoint(cluster);
            Vector3 clusterCenterPos = exchangeAxis.ModelIndex_to_unityPos((float)centerPos.x, (float)centerPos.y, (float)centerPos.z);
            double  distance         = GetDistance(pos, clusterCenterPos);
            //偏角
            double avertence = GetAvertence(pos, rot, clusterCenterPos);
            //兴趣度系数(需改进)
            //double coefficient = getCoefficient.GetCoefficeent(cluster);
            double coefficient = 0;
            double value       = coefficient + distance + avertence + clusterDes[count].gaze;
            if (distance < 10)
            {
                predicted_cluster = clusters[clusterDes[count].getMaxProId()];
                break;
            }
            //double value = clusterDes[count].gaze;

            count++;

            Debug.Log("=====兴趣度系数是" + value + "=====");
            //计算每个cluster的interest_value(需改进)加入数量?
            //只选取 “一个” 最优的cluster(需改进)
            if (value > maxValue)
            {
                maxValue          = value;
                predicted_cluster = cluster;
            }
        }
        return(predicted_cluster.ToList());
        //List<Record> Unitypos_predicted_cluster = new List<Record>();
        //List<Record> oho = predicted_cluster.ToList();
        //if (predicted_cluster!=null)
        //{
        //    foreach (var box in predicted_cluster)
        //    {
        //        Vector3 pos1 = exchangeAxis.ModelIndex_to_unityPos((float)box.posX, (float)box.posY,(float)box.posZ);
        //        Vector3 rot1 = new Vector3((float)box.rotX, (float)box.rotY, (float)box.rotZ);
        //        Unitypos_predicted_cluster.Add(new Record(pos1,rot1));

        //    }
        //}

        //return Unitypos_predicted_cluster;
    }
Пример #2
0
        public override void Execute(object source, DamageEventInfo info)
        {
            DamageInfo damage = info.Info;

            int   projCount = Mathf.RoundToInt(BaseProjectileCount.Get() * Coeffecient.Get());
            float step      = (StartAngle.Get() - EndAngle.Get()) / (projCount - (IncludeLast ? 1 : 0));

            for (int i = 0; i < projCount; i++)
            {
                float      angle         = StartAngle.Get() - step * i + (HalfOffset ? step / 2f : 0f);
                Vector3    dir           = Quaternion.Euler(0f, 0f, angle) * damage.Projectile.Direction;
                GameObject newProjectile = Object.Instantiate(damage.Projectile.gameObject, damage.Point, Quaternion.identity);
                Projectile projectile    = newProjectile.GetComponent <Projectile>();
                AttachProjectileToSources(projectile);
                projectile.SetProcLayer(damage.Projectile.ProcLayer + 1);
                projectile.Fire(damage.Projectile.Weapon, dir, damage.Projectile.Layer, damage.Projectile.Target, damage.Amount * DamageCoeffecient.Get(), damage.Projectile.Range * RangeCoeffecient.Get());
            }
        }
Пример #3
0
        public override void ApplyEffect(IModdable target)
        {
            _target = target;
            IStatContainer container = target as IStatContainer;
            Stat           stat      = container.GetStat(Identifier);

            //TODO: Consider having StatType be a member of Stat instead of StatMod, then handling how to add the stat in Stat.
            switch (Type)
            {
            case StatType.Additive:
                stat.AddAdditive(Value.Get() * Coeffecient.Get(), this);
                break;

            case StatType.Multiplicative:
                stat.AddMultiplicative(Value.Get() * Coeffecient.Get(), this);
                break;
            }
        }
        public override void Execute(object source, DamageEventInfo info)
        {
            DamageInfo damage       = info.Info;
            GameObject newExplosion = Object.Instantiate(ProjectilePrefab.Get() as GameObject, info.Info.Point, Quaternion.identity);
            Projectile proj         = newExplosion.GetComponent <Projectile>();

            proj.Fire(damage.Projectile.Weapon, damage.Projectile.Direction, damage.Projectile.Layer, damage.Projectile.Target, damage.Amount * DamageCoeffecient.Get(), Mathf.Sqrt(damage.Amount * AreaCoeffecient.Get() / Mathf.PI) * Coeffecient.Get());
            AttachProjectileToSources(proj);

            if (IncrementProcLayer)
            {
                proj.SetProcLayer(damage.Projectile.ProcLayer + 1);
            }
        }
Пример #5
0
        public override void Execute(object source, DamageEventInfo info)
        {
            DamageInfo damage        = info.Info;
            Vector2    newDirection  = Vector2.Reflect(damage.Projectile.Direction, damage.Normal);
            GameObject newProjectile = Object.Instantiate(damage.Projectile.gameObject, damage.Point, Quaternion.LookRotation(newDirection, Vector3.back));
            Projectile proj          = newProjectile.GetComponent <Projectile>();

            AttachProjectileToSources(proj);
            proj.Fire(damage.Projectile.Weapon, newDirection, damage.Projectile.Layer, damage.Projectile.Target, damage.Amount * DamageCoeffecient.Get() * Coeffecient.Get(), damage.Projectile.Range * RangeCoeffecient.Get());
        }
Пример #6
0
    public Cluster GetPredictedCluster(Vector3 pos, Vector3 rot, List <Cluster> clusterNet, List <Record> gazePoints)
    {
        var exchangeAxis = new ExchangeAxis();
        //Record[] predicted_cluster = null;
        Cluster predicted_cluster = null;
        double  maxValue          = -100;

        Debug.Log("现在朝向" + rot);
        Coeffecient getCoefficient = new Coeffecient();
        int         count          = 0;
        //List<Record[]> clusters= origin_clusters.ToList();
        Dictionary <int, double> _distanceDic = distanceDic(clusterNet, pos);
        var minPair = _distanceDic.Keys.Select(x => new { x, y = _distanceDic[x] }).OrderBy(x => x.y).First();
        var minId   = minPair.x;
        var minDis  = _distanceDic[minId];

        _distanceDic.Remove(minId);
        var secPair = _distanceDic.Keys.Select(x => new { x, y = _distanceDic[x] }).OrderBy(x => x.y).First();
        var secId   = secPair.x;
        var secDis  = _distanceDic[secId];

        if (Math.Abs(minDis - secDis) < 10)
        {
            if (Math.Abs(GetAvertence(pos, rot, clusterNet[minId].center)) < 0.25)
            {
                predicted_cluster = clusterNet[minId];
            }
            else
            {
                predicted_cluster = clusterNet[secId];
            }
        }
        else
        {
            foreach (var _cluster in clusterNet)
            {
                if (_cluster.id == minId)
                {
                    continue;
                }
                double value = _cluster.gazePro + clusterNet[minId].getPro(_cluster.id) + _cluster.getSilCoe(clusterNet[minId]);
                if (value > maxValue)
                {
                    maxValue          = value;
                    predicted_cluster = _cluster;
                }
            }
        }
        //foreach (var _cluster in clusterNet)
        //{
        //    //var cluster = _cluster.points;
        //    //数据块的距离(暂时按照cluster0计算)
        //    //Vector3 clusterCenterPos = exchangeAxis.ModelIndex_to_unityPos((float)cluster[0].posX, (float)cluster[0].posY, (float)cluster[0].posZ);
        //    Vector3 centerPos = _cluster.center;
        //    //Vector3 clusterCenterPos = exchangeAxis.ModelIndex_to_unityPos((float)centerPos.x, (float)centerPos.y, (float)centerPos.z);
        //    //double distance = GetDistance(pos,clusterCenterPos);
        //    double distance = GetDistance(pos, centerPos);
        //    //偏角
        //    //double avertence = GetAvertence(pos,rot, clusterCenterPos);
        //    double avertence = GetAvertence(pos, rot, centerPos);
        //    //兴趣度系数(需改进)
        //    //double coefficient = getCoefficient.GetCoefficeent(cluster);
        //    double coefficient = 0;
        //    double value = coefficient+distance+avertence + clusterNet[count].gaze;
        //    if(distance<10)
        //    {
        //        //predicted_cluster = clusters[clusterNet[count].getMaxProId()];
        //        predicted_cluster= clusterNet[clusterNet[count].getMaxProId()];
        //        break;
        //    }
        //    //double value = clusterNet[count].gaze;

        //    count++;

        //    Debug.Log("=====兴趣度系数是"+value+"=====");
        //    //计算每个cluster的interest_value(需改进)加入数量?
        //    //只选取 “一个” 最优的cluster(需改进)
        //    if (value > maxValue)
        //    {
        //        maxValue = value;
        //        predicted_cluster = _cluster;
        //    }
        //}
        return(predicted_cluster);
        //List<Record> Unitypos_predicted_cluster = new List<Record>();
        //List<Record> oho = predicted_cluster.ToList();
        //if (predicted_cluster!=null)
        //{
        //    foreach (var box in predicted_cluster)
        //    {
        //        Vector3 pos1 = exchangeAxis.ModelIndex_to_unityPos((float)box.posX, (float)box.posY,(float)box.posZ);
        //        Vector3 rot1 = new Vector3((float)box.rotX, (float)box.rotY, (float)box.rotZ);
        //        Unitypos_predicted_cluster.Add(new Record(pos1,rot1));

        //    }
        //}

        //return Unitypos_predicted_cluster;
    }