Inheritance: MonoBehaviour
        /// <inheritdoc />
        public async Task InfluenceAsync(CancellationToken cancellationToken, Guid userId, Guid eventId,
                                         Influence influence, DateTime created)
        {
            if (!cancellationToken.IsCancellationRequested)
            {
                Logger.LogInformation("Influencing");
                using var scope = ScopeFactory.CreateScope();
                var context    = scope.ServiceProvider.GetRequiredService <ApplicationContext>();
                var categories = context.Categories.Where(x => x.Events.Any(e => e.EventId == eventId)).ToList();
                var user       = await context.Users
                                 .Include(x => x.RecommendationScores).ThenInclude(x => x.Category)
                                 .FirstOrDefaultAsync(x => x.Id == userId);

                if (user == null)
                {
                    Logger.LogInformation("Couldn't find user when influencing");
                    return;
                }

                UpdateRecommendations(user, categories, context);

                await SaveAsync(context);

                Logger.LogInformation("Influenced");
            }
        }
Ejemplo n.º 2
0
 private void addInfluenceToSelectedRegions(Influence influence)
 {
     foreach (Region region in influence.GetRegions())
     {
         addSelectedRegion(region);
     }
 }
Ejemplo n.º 3
0
        private void ChangeOfCharacteristicLTextBox_Initialized(object sender, EventArgs e)
        {
            TextBox ChangeOfCharacteristicTextBox = sender as TextBox;

            Influence influence = ChangeOfCharacteristicTextBox.DataContext as Influence;

            if (influence.Value == defaultInfluenceValue)
            {
                var characeristicName = influence.Characteristic.Name;

                if (characeristicName[characeristicName.Length - 1] == 'ы')
                {
                    ChangeOfCharacteristicTextBox.Text = characeristicName + defaultInfluenceTextPlural;
                }

                else
                {
                    ChangeOfCharacteristicTextBox.Text = characeristicName + defaultInfluenceText;
                }

                ChangeOfCharacteristicTextBox.Foreground = Brushes.Gray;
            }

            else
            {
                ChangeOfCharacteristicTextBox.Text = influence.Value.ToString();
            }
        }
Ejemplo n.º 4
0
 private void removeInfluenceFromSelectedRegions(Influence influence)
 {
     foreach (Region region in influence.GetRegions())
     {
         removeSelectedRegion(region);
     }
 }
Ejemplo n.º 5
0
 private void Healing()
 {
     foreach ( var key in units ) {
         Influence influence = new Influence();
         influence.healing = 5;
         key.GetDamage( influence );
     }
 }
Ejemplo n.º 6
0
 void IAttachable <Influence> .Add(Influence element)
 {
     if (element == null)
     {
         throw new ArgumentNullException();
     }
     _influences.Remove(element);
 }
        // calculates the new recommendation score weight
        private double CalculateWeight(double weight, Influence influence)
        {
            double multiplier = ((double)influence / 1000) + 1;

            weight *= multiplier;
            Logger.LogInformation("Updated weight {Weight}, {Multiplier}", weight, multiplier);
            return(weight);
        }
Ejemplo n.º 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            Influence influence = db.Influences.Find(id);

            db.Influences.Remove(influence);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 9
0
 public void ModifyModelWithData(GameObject modelToModify, string data)
 {
     if (!string.IsNullOrEmpty(data) && !string.IsNullOrWhiteSpace(data))
     {
         Influence.AddInfluence(modelToModify, data, 20, 20, 46);
     }
     //else
     //    Debug.Log("Handler tried to add Influence component with empty or null name.");
 }
Ejemplo n.º 10
0
    void OnStart()
    {
        leftClick      = GameObject.Find("Mouse Click").GetComponent <AudioSource>();
        mouseInfluence = GameObject.Find("Mouse Influence").GetComponent <Influence>();
        myMouse        = GameObject.Find("Mouse Token");
        rbMouse        = myMouse.GetComponent <Rigidbody>();

        isLive = true;
    }
Ejemplo n.º 11
0
    public void GetDamage(Influence influence )
    {
        if ( influence.timeEffect != null ) {
            if(influence.timeEffect.visualPrefab != null)
            unitView.SetEffectParticle( influence.timeEffect.visualPrefab );
        }

        unitModel.GetDamage( influence );
    }
Ejemplo n.º 12
0
 public ActionResult Edit([Bind(Include = "ID,Name,Description,BeginYear,EndYear")] Influence influence)
 {
     if (ModelState.IsValid)
     {
         db.Entry(influence).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(influence));
 }
Ejemplo n.º 13
0
        public override void ApplyEffectKind(Troop troop)
        {
            Influence t = Session.Current.Scenario.GameCommonData.AllInfluences.GetInfluence(this.number);

            if (t != null)
            {
                troop.EventInfluences.Add(t);
                t.ApplyInfluence(troop, Applier.Event, 0);
            }
        }
Ejemplo n.º 14
0
 public void drawInfluence(Graphics g, Influence inf)
 {
     if (inf != null && inf.GetRegions().Count > 0)
     {
         foreach (Region region in inf.GetRegions())
         {
             drawRegion(g, region);
         }
     }
 }
Ejemplo n.º 15
0
    void OnTriggerExit( Collider other )
    {
        if ( other.GetComponent<UnitViewPresenter>() && other.GetComponent<UnitViewPresenter>().faction == faction ) {
            Influence influence = new Influence();
            influence.timeEffect = EfffectOn( 1 );

            units.Remove( other.GetComponent<UnitViewPresenter>() );

            other.GetComponent<UnitViewPresenter>().GetDamage( influence );
        }
    }
Ejemplo n.º 16
0
        public ActionResult Create([Bind(Include = "ID,Name,Description,BeginYear,EndYear")] Influence influence)
        {
            if (ModelState.IsValid)
            {
                db.Influences.Add(influence);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(influence));
        }
Ejemplo n.º 17
0
    void OnTriggerEnter( Collider other )
    {
        Debug.Log( "other: " + other.name );
        if ( other.GetComponent<UnitViewPresenter>() && other.GetComponent<UnitViewPresenter>().faction == faction ) {
            Influence influence = new Influence();
            influence.timeEffect = EfffectOn( 99999 );

            units.Add( other.GetComponent<UnitViewPresenter>() );

            other.GetComponent<UnitViewPresenter>().GetDamage( influence );
        }
    }
Ejemplo n.º 18
0
    public override void GetDamage( Influence influence )
    {
        if ( currentHp > 0 ) {
            currentHp -= (int)( influence.damage * ( 1 - currentCharacteristics.armor ) );

            if ( currentHp <= 0 ) {
                currentHp = 0;
                setUpdeteCharacteristicsDelegate( UpdateBaseCharacteristics, true );
                updateDeath();
            }
        }
    }
Ejemplo n.º 19
0
 public override void ApplyEffectKind(Person person)
 {
     if (person.LocationTroop != null)
     {
         Influence t = Session.Current.Scenario.GameCommonData.AllInfluences.GetInfluence(this.number);
         if (t != null)
         {
             person.LocationTroop.EventInfluences.Add(t);
             t.ApplyInfluence(person.LocationTroop, Applier.Event, 0);
         }
     }
 }
Ejemplo n.º 20
0
        private void ChangeOfCharacteristicLTextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            TextBox ChangeOfCharacteristicLTextBox = sender as TextBox;

            Influence influence = ChangeOfCharacteristicLTextBox.DataContext as Influence;

            if (influence.Value == defaultInfluenceValue)
            {
                ChangeOfCharacteristicLTextBox.Text = "";
            }

            ChangeOfCharacteristicLTextBox.Foreground = Brushes.Black;
        }
Ejemplo n.º 21
0
    public static void Main()
    {
        const int  N             = 10000;
        const long SecondInTicks = 10000000;

        var vertices   = new Vertex[N];
        var influences = new Influence[N];

        for (int i = 0; i < N; i++)
        {
            vertices[i] = new Vertex {
                Position = new CalVector4(1, 2, 3),
                Normal   = new CalVector4(0, 0, 1)
            };

            influences[i] = new Influence {
                BoneId = 0,
                Weight = 1.0f,
                LastInfluenceForThisVertex = true
            };
        }

        var boneTransforms = new BoneTransform[] {
            new BoneTransform()
        };

        var output = new CalVector4[N * 2];

        for (int i = 0; i < 100; i++)
        {
            long verticesSkinned = 0;
            long started         = DateTime.UtcNow.Ticks;

            while (DateTime.UtcNow.Ticks < (started + SecondInTicks))
            {
                CalculateVerticesAndNormals(
                    boneTransforms, N, vertices, influences, output
                    );

                verticesSkinned += N;
            }

            long elapsed = DateTime.UtcNow.Ticks - started;

            Console.WriteLine(
                "Skinned vertices per second: {0}",
                (verticesSkinned * SecondInTicks) / elapsed
                );
        }
    }
Ejemplo n.º 22
0
    public void init()
    {
        Influence player   = new Influence(INFLUENCE_PLAYER);
        Influence fireStar = new Influence(INFLUENCE_FIRE_STAR);
        Influence earth    = new Influence(INFLUENCE_EARTH);

        add(player);
        add(fireStar);
        add(earth);
        player.addHostileInfluence(fireStar.Name);
        earth.addHostileInfluence(fireStar.Name);
        fireStar.addHostileInfluence(earth.Name);
        fireStar.addHostileInfluence(player.Name);
    }
Ejemplo n.º 23
0
        /// <summary>
        /// parsing the xml
        /// atribute: target, influence, offsetAngle, offsetDirection
        /// sync point: start, ready, relax, end
        /// </summary>
        /// <param name="reader"></param>
        public override void Parse(XmlReader reader)
        {
            base.Parse(reader);

            target          = TryParseAtribute <string>(reader, "target", "", true);
            influence       = TryParseAtribute <Influence>(reader, "influence", Influence.NONE, false);
            offsetAngle     = TryParseAtribute <float>(reader, "offsetAngle", 0.0f, false);
            offsetDirection = TryParseAtribute <Direction>(reader, "offsetDirection", Direction.RIGHT, false);

            TryParseSyncPoint(reader, "start");
            TryParseSyncPoint(reader, "ready");
            TryParseSyncPoint(reader, "relax");
            TryParseSyncPoint(reader, "end");
        }
Ejemplo n.º 24
0
        // GET: Influences/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Influence influence = db.Influences.Find(id);

            if (influence == null)
            {
                return(HttpNotFound());
            }
            return(View(influence));
        }
Ejemplo n.º 25
0
        public void SelectCurInfluence(int x, int y)
        {
            Influence inf = translateToInfluence(x, y);

            if (inf != null)
            {
                if (curInfluence == inf)
                {
                    curInfluence = null;
                }
                else
                {
                    curInfluence = inf;
                }
            }
        }
Ejemplo n.º 26
0
        public static bool AddInfluenceExplicit(Influence influence, IRandom random, Equipment item, AffixManager affixManager, CurrencyModifiers currencyModifiers)
        {
            var equipmentModifiers = new EquipmentModifiers(item);
            var affix = affixManager.GetInfluenceAffix(influence, equipmentModifiers, item.Stats.Select(x => x.Affix).ToList(), item.Rarity, random);

            if (affix == null)
            {
                return(false);
            }

            var stat = AffixToStat(random, item, affix);

            item.Stats.Add(stat);

            return(true);
        }
Ejemplo n.º 27
0
        private void ChangeOfCharacteristicLTextBox_LostFocus(object sender, RoutedEventArgs e)
        {
            TextBox ChangeOfCharacteristicLTextBox = sender as TextBox;

            Influence influence = ChangeOfCharacteristicLTextBox.DataContext as Influence;

            bool intParsing = int.TryParse(ChangeOfCharacteristicLTextBox.Text, out int val);

            if (intParsing && influence.Value != val)
            {
                influence.Value = val;

                _wereThereAlreadySomeChangings = true;
            }

            ChangeOfCharacteristicLTextBox.Text = influence.Value.ToString();
        }
Ejemplo n.º 28
0
        public override Influence Do()
        {
            Influence influence = new Influence();

            if (coroutine == null)
            {
                influence = influence.HorizontalMovement(speedIncrease);
            }
            else
            {
                StopCoroutine(coroutine);
            }

            StartCoroutine(coroutine = ChangeSprite());

            return(influence);
        }
Ejemplo n.º 29
0
        public void Influence(Influence influence)
        {
            if (influence.StartToListen())
            {
                startedToListen = true;
            }

            if (influence.Die())
            {
                dead = true;
                animator.StartAnimation(Animation.EXPLOSION, state.GetDirection(), () =>
                {
                    afterimaging.StopShowingAfterimages();
                    instantiater.Clone();
                });
            }

            if (influence.StartMoving())
            {
                state.StartMoving();
            }

            if (influence.StopMoving())
            {
                state.StopMoving();
            }

            if (influence.TurnAround())
            {
                state.TurnAround();
            }

            bonusSpeed    += influence.HorizontalMovement();
            verticalSpeed += influence.VerticalMovement();

            Move(new Vector2(influence.Reposition().x, influence.Reposition().y));

            Vector2?place = influence.Place();

            if (place != null)
            {
                transform.position = (Vector2)place;
            }
        }
Ejemplo n.º 30
0
 public void NewSelectedInfluence()
 {
     if (selectedRegions.Count > 0)
     {
         Influence newInfluence = new Influence();
         int       argb         = new Random().Next();
         newInfluence.Color = Color.FromArgb((int)(argb | 0XFF000000));;
         foreach (Region region in selectedRegions)
         {
             newInfluence.AddRegion(region);
             if (region.Influence != null)
             {
                 region.Influence.RemoveRegion(region);
             }
             region.Influence = newInfluence;
         }
         selectedRegions.Clear();
     }
 }
Ejemplo n.º 31
0
        public Affix GetInfluenceAffix(Influence influence, EquipmentModifiers equipmentModifiers, List <Affix> affixes, EquipmentRarity rarity, IRandom random)
        {
            var existingGroups = new HashSet <string>(affixes.Select(x => x.Group));

            int affixesCount = rarity == EquipmentRarity.Normal ? 0 :
                               rarity == EquipmentRarity.Magic ? 1 :
                               rarity == EquipmentRarity.Rare ? 3 : 0;

            HashSet <string> fullGenTypes = new HashSet <string>();

            if (affixes.Count(x => x.GenerationType == "suffix") >= affixesCount)
            {
                fullGenTypes.Add("suffix");
            }
            if (affixes.Count(x => x.GenerationType == "prefix") >= affixesCount)
            {
                fullGenTypes.Add("prefix");
            }

            var pool = _influenceAffixes[influence]
                       .Where(x => x.RequiredLevel <= equipmentModifiers.ItemLevel)
                       .Where(x => !existingGroups.Contains(x.Group))
                       .Where(x => !fullGenTypes.Contains(x.GenerationType))
                       .ToList();

            var tag = _influenceTags[influence];

            var currentWeight = pool.Sum(x => x.SpawnWeights[tag]);
            var randomValue   = random.Next(currentWeight);

            foreach (var affix in pool)
            {
                currentWeight -= affix.Weight;
                if (randomValue < currentWeight)
                {
                    return(affix);
                }
            }
            throw new InvalidOperationException("An affix should have been selected");
        }
Ejemplo n.º 32
0
        public override int GetHashCode()
        {
            //https://stackoverflow.com/a/892640/3131828
            unchecked
            {
                int h = 23;
                h *= 31 + (Name?.GetHashCode() ?? 0);
                h *= 31 + (FactionState?.GetHashCode() ?? 0);
                h *= 31 + (Government?.GetHashCode() ?? 0);
                h *= 31 + Influence.GetHashCode();
                h *= 31 + (Allegiance?.GetHashCode() ?? 0);
                h *= 31 + (MyReputation?.GetHashCode() ?? 0);
                h *= 31 + SquadronFaction.GetHashCode();
                h *= 31 + HappiestSystem.GetHashCode();
                h *= 31 + HomeSystem.GetHashCode();
                h *= 31 + (PendingStates?.GetHashCode() ?? 0);
                h *= 31 + (RecoveringStates?.GetHashCode() ?? 0);
                h *= 31 + (ActiveStates?.GetHashCode() ?? 0);

                return(h);
            }
        }
Ejemplo n.º 33
0
        private void InfluenceValueTextBlock_Initialized(object sender, EventArgs e)
        {
            TextBlock InfluenceValueTextBlock = sender as TextBlock;

            Grid CharacteristicGrid = InfluenceValueTextBlock.Parent as Grid;

            TextBlock CharacteristicValueTextBlock = CharacteristicGrid.Children[0] as TextBlock;

            Characteristic characteristic = InfluenceValueTextBlock.DataContext as Characteristic;

            Influence influence = _reaction.Influences.FirstOrDefault(inf => inf.Characteristic.Name == characteristic.Name);

            characteristic.Value += influence.Value;

            CharacteristicValueTextBlock.Text = characteristic.Value.ToString();

            if (influence.Value > 0)
            {
                InfluenceValueTextBlock.Foreground = Brushes.ForestGreen;

                InfluenceValueTextBlock.Text = "(+" + influence.Value + ")";
            }

            else if (influence.Value < 0)
            {
                InfluenceValueTextBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFF2323"));

                InfluenceValueTextBlock.Text = "(" + influence.Value + ")";
            }

            else
            {
                InfluenceValueTextBlock.Foreground = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FF64606B"));

                InfluenceValueTextBlock.Text = "(" + influence.Value + ")";
            }
        }
Ejemplo n.º 34
0
    public virtual void GetDamage( Influence influence )
    {
        if ( currentHp > 0 ) {
            currentHp -= (int)( influence.damage * ( 1 - currentCharacteristics.armor ) );
            currentHp += (int)influence.healing;

            //Debug.Log( "currentHp: " + currentHp );

            if ( currentHp <= 0 ) {
                currentHp = 0;
                if ( influence.owner.unitType == UnitType.hero ) {
                    //FIXME GetGold to EntityController
                    influence.owner.GetGold( gold );
                    ((HeroViewPresentor)influence.owner).GetXP( xp );
                }
                setUpdeteCharacteristicsDelegate( UpdateBaseCharacteristics, true );
                updateDeath();
            }
            //-> targetController->View.Updatehp
            //->targetController.Hit->stateModel.Hit->( если возможно )->controller->view->HitAnimation

            if ( influence.timeEffect != null ) {
                AddEffect( influence.timeEffect );
            }
        }
    }
Ejemplo n.º 35
0
    private Influence GetInfluence()
    {
        Influence tempInfluence = new Influence();
        tempInfluence.damage = currentCharacteristics.attack;

        return tempInfluence;
    }
Ejemplo n.º 36
0
 private ContentFilterPhrase(string phrase, Influence influence) : base(new SimpleProviderPropertyBag())
 {
     this.Phrase    = phrase;
     this.Influence = influence;
 }
Ejemplo n.º 37
0
 public void ReadLODs()
 {
     int count = BitConverter.ToInt32(memory, readerpos);
     readerpos += 4;
     Mesh.LODs = new List<LOD>();
     for (int i = 0; i < count; i++)
     {
         LOD lod = new LOD();
         lod._offset = readerpos;
         lod.Headers = new List<LODHeader>();
         int sectioncount = BitConverter.ToInt32(memory, readerpos);
         readerpos += 4;
         for (int j = 0; j < sectioncount; j++)
         {
             LODHeader lodsec = new LODHeader();
             lodsec.matindex = BitConverter.ToUInt16(memory, readerpos);
             lodsec.index = BitConverter.ToUInt16(memory, readerpos + 2);                    
             lodsec.offset = BitConverter.ToUInt32(memory, readerpos + 4);
             lodsec.count = BitConverter.ToUInt16(memory, readerpos + 8);
             lodsec.unk1 = BitConverter.ToUInt16(memory, readerpos + 10);
             readerpos += 12;
             lod.Headers.Add(lodsec);
         }
         int indexsize = BitConverter.ToInt32(memory, readerpos);
         int indexcount = BitConverter.ToInt32(memory, readerpos + 4);
         readerpos += 8;
         lod.Indexes = new List<ushort>();
         for (int j = 0; j < sectioncount; j++)
         {
             for (int k = 0; k < lod.Headers[j].count * 3; k++)
             {
                 lod.Indexes.Add(BitConverter.ToUInt16(memory, readerpos));
                 readerpos += 2;
             }
         }
         indexcount = BitConverter.ToInt32(memory, readerpos); // ?? SoftVertices ??
         readerpos += 4;
         if (indexcount != 0)
         {
             MessageBox.Show("Not implemented!");
             return;
         }
         indexcount = BitConverter.ToInt32(memory, readerpos); // ?? RigidVertices ??
         readerpos += 4;
         lod.UnkIndexes1 = new List<ushort>();
         for (int k = 0; k < indexcount; k++)
         {
             lod.UnkIndexes1.Add(BitConverter.ToUInt16(memory, readerpos));
             readerpos += 2;
         }
         indexcount = BitConverter.ToInt32(memory, readerpos); // ?? ShadowIndices ??
         readerpos += 4;
         if (indexcount != 0)
         {
             MessageBox.Show("Not implemented!");
             return;
         }
         lod.UnkCount1 = BitConverter.ToInt32(memory, readerpos); // ?? Sections ??
         readerpos += 4;
         lod.UnkIndexes2 = new List<UInt32>();
         for (int k = 0; k < 3; k++)                         // ?? Rot/Loc ??
         {
             lod.UnkIndexes2.Add(BitConverter.ToUInt32(memory, readerpos));
             readerpos += 4;
         }
         lod.UnkSec1 = new List<UnknownSection>();
         for (int k = 0; k < lod.UnkCount1; k++)    // ?? Sections ?? Materials ??
         {
             UnknownSection unk = new UnknownSection();
             indexcount = BitConverter.ToInt32(memory, readerpos);
             readerpos += 4;
             unk.Indexes = new List<ushort>();
             for (int l = 0; l < indexcount; l++) // ?? active bones ??
             {
                 unk.Indexes.Add(BitConverter.ToUInt16(memory, readerpos));
                 readerpos += 2;
             }
             unk.Unkn = new byte[24];
             for (int l = 0; l < 24; l++)
                 unk.Unkn[l] = memory[readerpos + l];
             readerpos += 24;
             lod.UnkSec1.Add(unk);
         }
         indexcount = BitConverter.ToInt32(memory, readerpos);
         readerpos += 4;
         lod.ActiveBones = new List<byte>();
         for (int k = 0; k < indexcount; k++)
             lod.ActiveBones.Add(memory[readerpos + k]);
         readerpos += indexcount;
         lod.UnkSec2 = new byte[48];
         for (int k = 0; k < 48; k++)
             lod.UnkSec2[k] = memory[readerpos + k];
         readerpos += 48;
         indexsize = BitConverter.ToInt32(memory, readerpos);
         indexcount = BitConverter.ToInt32(memory, readerpos + 4);
         readerpos += 8;
         lod.Edges = new List<Edge>();
         for (int k = 0; k < indexcount; k++)
         {
             Edge e = new Edge();
             e._offset = readerpos;
             e.Unk1 = BitConverter.ToInt32(memory, readerpos);
             e.Unk2 = BitConverter.ToInt32(memory, readerpos + 4);
             e.Influences = new List<Influence>();
             for (int l = 0; l < 4; l++)
             {
                 Influence inf = new Influence();
                 inf.bone = memory[readerpos + 8 + l];
                 inf.weight = memory[readerpos + 12 + l];
                 e.Influences.Add(inf);
             }
             e.Position = ReadVector(readerpos + 16);
             UInt16 u = BitConverter.ToUInt16(memory, readerpos + 28);
             UInt16 v = BitConverter.ToUInt16(memory, readerpos + 30); 
             e.UV = new Vector2(HalfToFloat(u), HalfToFloat(v));
             e._imported = false;
             lod.Edges.Add(e);
             readerpos += 32;
         }
         lod.unk2 = BitConverter.ToUInt32(memory, readerpos);
         readerpos += 4;                
         Mesh.LODs.Add(lod);
     }
 }
Ejemplo n.º 38
0
    private void ActivateSpell()
    {
        if ( (spellWithTarget && spellTarget == null) || (spellTarget != null && Vector3.Distance( spellTarget.transform.position, myViewPresenter.transform.position ) > spell.attackRange) ) {
            fsm.CallEvent( FiniteStateMachine.Events.TargetLost );
            return;
        }

        Vector3 tempPos = spellTargetPosition;
        Influence tempInfluence;

        UnitViewPresenter tempSpellTarget = spellTarget;
        spellTarget = null;
        if ( tempSpellTarget != null ) {

            tempPos = tempSpellTarget.transform.position;

            myViewPresenter.transform.LookAt( tempPos );

            animationController.AttackAnimation();

            tempInfluence = new Influence();
            tempInfluence.damage = 50;
            tempInfluence.healing = 0;
            tempInfluence.owner = myViewPresenter;

            tempInfluence.timeEffect = spell.effect;

            if ( tempSpellTarget.faction != myFaction ) {
                tempSpellTarget.GetDamage( tempInfluence );
                spell.cd = true;
            } else {
                fsm.CallEvent( FiniteStateMachine.Events.TargetLost );
                return;
            }

        } else {

            myViewPresenter.transform.LookAt( tempPos );

            animationController.AttackAnimation();

            tempInfluence = new Influence();
            tempInfluence.damage = 25;
            tempInfluence.healing = 0;
            tempInfluence.owner = myViewPresenter;

            tempInfluence.timeEffect = null;
            RaycastHit[] hit;
            hit = Physics.SphereCastAll( tempPos, spell.aoeRadius, Vector3.forward);

           GameObject tempEffect = (GameObject) GameObject.Instantiate( spell.effect.visualPrefab, tempPos + new Vector3( 0, 5.5f, 0 ), spell.effect.visualPrefab.transform.rotation);

            tempEffect.GetComponent<ParticleSystem>().Play();

            foreach ( var key in hit ) {
                UnitViewPresenter uvp;

                if ( key.transform.GetComponent<UnitViewPresenter>() ) {
                    uvp = key.transform.GetComponent<UnitViewPresenter>();

                    if ( uvp.faction != myFaction ) {
                        uvp.GetDamage( tempInfluence );
                    }

                    spell.cd = true;

                }
            }
        }

        Spell tempSpell = spell;

        Action temp = () => {
            tempSpell.cd = false;
        };

        SceneManager.Instance.CoroutineManager.InvokeAttack( temp, spell.cdTime );

        fsm.CallEvent( FiniteStateMachine.Events.TargetApproached );
    }
Ejemplo n.º 39
0
 public void GetDamage(Influence influence )
 {
     damageDelegate( influence );
 }
Ejemplo n.º 40
0
 void Awake()
 {
     instance = this;
 }
Ejemplo n.º 41
0
 protected void _UpdateCharacteristics(BaseUnit.UnitCharacteristics newCharacteristics, Influence influence )
 {
     if ( tempNavMeshAgent != null ) {
         tempNavMeshAgent.speed = newCharacteristics.speed;
         unitBehaviour.SetAttackParam( newCharacteristics.attackSpeed, newCharacteristics.attackRange );
         unitBehaviour.SetInfluence( influence );
     }
 }
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = new Influence[3];
     for(int i = 0;i < _Field0.Length;i++)
     {
         _Field0[i] = new Influence();
         _Field0[i].Parse(buffer);
     }
 }
Ejemplo n.º 43
0
    public static void CalculateVerticesAndNormals(
        BoneTransform[] boneTransforms,
        int vertexCount,
        Vertex[] vertices,
        Influence[] influences,
        CalVector4[] output
    )
    {
        Debug.Assert(output.Length == vertices.Length * 2);

        BoneTransform totalTransform;

        for (
            int sourceVertex = 0, sourceInfluence = 0, outputVertex = 0;
            sourceVertex < vertices.Length;
            sourceVertex++, sourceInfluence++, outputVertex += 2
        ) {
            var influence = influences[sourceInfluence];

            boneTransforms[influence.BoneId].Scale(
                out totalTransform, influence.Weight
            );

            while (!influence.LastInfluenceForThisVertex) {
                sourceInfluence += 1;
                influence = influences[sourceInfluence];

                boneTransforms[influence.BoneId].AddScaled(
                    ref totalTransform, influence.Weight
                );
            }

            totalTransform.TransformPoint(
                out output[outputVertex], ref vertices[sourceVertex].Position
            );
            totalTransform.TransformVector(
                out output[outputVertex + 1], ref vertices[sourceVertex].Normal
            );
        }
    }
Ejemplo n.º 44
0
 void Start()
 {
     normal = 1f;
     election = GetComponent<Election>();
     influence = GetComponent<Influence>();
     revolution = GetComponent<Revolution>();
     oppositionDelta = -1;
     netGrowth = 0;
     //		StartCoroutine(Run());
     prompt = false;
 }
Ejemplo n.º 45
0
    public static void Main()
    {
        const int N = 10000;
        const long SecondInTicks = 10000000;

        var vertices = new Vertex[N];
        var influences = new Influence[N];

        for (int i = 0; i < N; i++) {
            vertices[i] = new Vertex {
                Position = new CalVector4(1, 2, 3),
                Normal = new CalVector4(0, 0, 1)
            };

            influences[i] = new Influence {
                BoneId = 0,
                Weight = 1.0f,
                LastInfluenceForThisVertex = true
            };
        }

        var boneTransforms = new BoneTransform[] {
            new BoneTransform()
        };

        var output = new CalVector4[N * 2];

        for (int i = 0; i < 100; i++) {
            long verticesSkinned = 0;
            long started = DateTime.UtcNow.Ticks;

            while (DateTime.UtcNow.Ticks < (started + SecondInTicks)) {
                CalculateVerticesAndNormals(
                    boneTransforms, N, vertices, influences, output
                );

                verticesSkinned += N;
            }

            long elapsed = DateTime.UtcNow.Ticks - started;

            Console.WriteLine(
                "Skinned vertices per second: {0}",
                (verticesSkinned * SecondInTicks) / elapsed
            );
        }
    }
Ejemplo n.º 46
0
 public void AddInfluence(Influence influence)
 {
     this.Influences.AddInfluence(influence);
 }
Ejemplo n.º 47
0
 public virtual void SetInfluence(Influence influence )
 {
     this.influence = influence;
 }