Inheritance: MonoBehaviour
Example #1
0
File: Game.cs Project: Zylann/GGJ14
    public void Initialize()
    {
        // Finding GameObjects
        m_object_player = GameObject.Find("Player");
        m_object_helpers = GameObject.Find ("Helpers");
        m_object_duckfield = GameObject.Find("Duckfield");
        m_object_audio = GameObject.Find("Audio");
        m_object_cameraman = GameObject.Find("Main Camera");

        // Finding Components
        m_collision_prober = m_object_player.GetComponent<CollisionProber>();
        m_scoring = m_object_player.GetComponent<Scoring>();
        m_health = m_object_player.GetComponent<Health>();
        m_walker = m_object_player.GetComponent<Walker>();
        m_jumper = m_object_player.GetComponent<Jumper>();

        m_time_helper = m_object_helpers.GetComponent<TimeHelper>();
        m_screen_helper = m_object_helpers.GetComponent<ScreenHelper>();

        m_duckfield = m_object_duckfield.GetComponent<DuckField>();

        m_duckization = m_object_audio.GetComponent<DuckizationController>();

        m_cameraman = m_object_cameraman.GetComponent<Cameraman>();
        m_ig_menu = m_object_cameraman.GetComponent<IgMenu>();
    }
Example #2
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
     }
     walker.PostWalk(this);
 }
Example #3
0
    /*
    ** 2008 August 16
    **
    ** The author disclaims copyright to this source code.  In place of
    ** a legal notice, here is a blessing:
    **
    **    May you do good and not evil.
    **    May you find forgiveness for yourself and forgive others.
    **    May you share freely, never taking more than you give.
    **
    *************************************************************************
    ** This file contains routines used for walking the parser tree for
    ** an SQL statement.
    *************************************************************************
    **  Included in SQLite3 port to C#-SQLite;  2008 Noah B Hart
    **  C#-SQLite is an independent reimplementation of the SQLite software library
    **
    **  SQLITE_SOURCE_ID: 2010-08-23 18:52:01 42537b60566f288167f1b5864a5435986838e3a3
    **
    *************************************************************************
    */
    //#include "sqliteInt.h"
    //#include <stdlib.h>
    //#include <string.h>


    /*
    ** Walk an expression tree.  Invoke the callback once for each node
    ** of the expression, while decending.  (In other words, the callback
    ** is invoked before visiting children.)
    **
    ** The return value from the callback should be one of the WRC_*
    ** constants to specify how to proceed with the walk.
    **
    **    WRC_Continue      Continue descending down the tree.
    **
    **    WRC_Prune         Do not descend into child nodes.  But allow
    **                      the walk to continue with sibling nodes.
    **
    **    WRC_Abort         Do no more callbacks.  Unwind the stack and
    **                      return the top-level walk call.
    **
    ** The return value from this routine is WRC_Abort to abandon the tree walk
    ** and WRC_Continue to continue.
    */
    static int sqlite3WalkExpr( Walker pWalker, ref Expr pExpr )
    {
      int rc;
      if ( pExpr == null )
        return WRC_Continue;
      testcase( ExprHasProperty( pExpr, EP_TokenOnly ) );
      testcase( ExprHasProperty( pExpr, EP_Reduced ) );
      rc = pWalker.xExprCallback( pWalker, ref pExpr );
      if ( rc == WRC_Continue
      && !ExprHasAnyProperty( pExpr, EP_TokenOnly ) )
      {
        if ( sqlite3WalkExpr( pWalker, ref pExpr.pLeft ) != 0 )
          return WRC_Abort;
        if ( sqlite3WalkExpr( pWalker, ref pExpr.pRight ) != 0 )
          return WRC_Abort;
        if ( ExprHasProperty( pExpr, EP_xIsSelect ) )
        {
          if ( sqlite3WalkSelect( pWalker, pExpr.x.pSelect ) != 0 )
            return WRC_Abort;
        }
        else
        {
          if ( sqlite3WalkExprList( pWalker, pExpr.x.pList ) != 0 )
            return WRC_Abort;
        }
      }
      return rc & WRC_Abort;
    }
Example #4
0
        public void ImpossibleTrajectory()
        {
            this.walker = new Walker(new Board(5, 9));

            Coord from = new Coord(0, 7), to = new Coord(4, 1);
            this.AssertBestProbToArrive(from, to, 0);
        }
 internal static SemanticMap From(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken)
 {
     var map = new SemanticMap();
     var walker = new Walker(semanticModel, map, cancellationToken);
     walker.Visit(node);
     return map;
 }
Example #6
0
        public void TwoHopTrajectory()
        {
            this.walker = new Walker(new Board(5, 5));

            Coord from = new Coord(0, 3), to = new Coord(2, 1);
            this.AssertBestProbToArrive(from, to, 0.25f);
        }
Example #7
0
        public void ReadGlow(GlowContainer glow, Client client)
        {
            var rootItem = new Item(null, _rootKey.Name, false, _rootKey);

             var walker = new Walker(this, client, rootItem);
             walker.Walk(glow);
        }
 void WalkNodes(TreeNodeCollection nodes, Walker walker)
 {
     foreach (TreeNode n in nodes)
     {
         walker(n);
         WalkNodes(n.Nodes, walker);
     }
 }
Example #9
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         _function.Walk(walker);
     }
     walker.PostWalk(this);
 }
Example #10
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         foreach (var v in _vars)
             v.Walk(walker);
     }
     walker.PostWalk(this);
 }
Example #11
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         _left.Walk(walker);
         _right.Walk(walker);
     }
     walker.PostWalk(this);
 }
Example #12
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         if (_expression != null)
             _expression.Walk(walker);
     }
     walker.PostWalk(this);
 }
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         foreach (var expr in _values)
             expr.Walk(walker);
     }
     walker.PostWalk(this);
 }
Example #14
0
    void Awake()
    {
	    GameManager.instance.staff.Add(this);
	    remainingNames=new List<string>(nameArray);
	    walker = gameObject.AddComponent<Walker>();
	    staffRenderer=GetComponentInChildren<StaffRenderer>();
	    selectionArrow=GetComponentInChildren<Bounce>().gameObject;
	    selectionArrow.SetActive(false);
        assignmentProgress = -1;
    }
Example #15
0
    void Awake()
    {
        GameManager.instance.jammers.Add(this);
	    walker = gameObject.AddComponent<Walker>();
	    walker.isJammer=true;
	    GenerateJammerName();

        trollStaff = gameObject.GetComponentInChildren<TrollStaff>();
        wifiProblem = gameObject.GetComponentInChildren<WiFiProblem>();
    }
Example #16
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         foreach (var val in _values)
         {
             val.Walk(walker);
         }
     }
     walker.PostWalk(this);
 }
Example #17
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         if (_target != null)
         {
             _target.Walk(walker);
         }
     }
     walker.PostWalk(this);
 }
Example #18
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         if (_expr != null)
         {
             _expr.Walk(walker);
         }
     }
     walker.PostWalk(this);
 }
Example #19
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         if (_defaultValue != null)
         {
             _defaultValue.Walk(walker);
         }
     }
     walker.PostWalk(this);
 }
Example #20
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         _name.Walk(walker);
         if (_initializationValue != null)
         {
             _initializationValue.Walk(walker);
         }
     }
     walker.PostWalk(this);
 }
Example #21
0
 /*
 ** Call sqlite3WalkExpr() for every expression in list p or until
 ** an abort request is seen.
 */
 static int sqlite3WalkExprList( Walker pWalker, ExprList p )
 {
   int i;
   ExprList_item pItem;
   if ( p != null )
   {
     for ( i = p.nExpr; i > 0; i-- )
     {//, pItem++){
       pItem = p.a[p.nExpr - i];
       if ( sqlite3WalkExpr( pWalker, ref pItem.pExpr ) != 0 ) return WRC_Abort;
     }
   }
   return WRC_Continue;
 }
Example #22
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         foreach (var tp in _testPairs)
         {
             tp.Item1.Walk(walker);
             tp.Item2.Walk(walker);
         }
         if (_ifFalse != null)
             _ifFalse.Walk(walker);
     }
     walker.PostWalk(this);
 }
Example #23
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         if (_statements != null)
         {
             foreach (Statement s in _statements)
             {
                 s.Walk(walker);
             }
         }
     }
     walker.PostWalk(this);
 }
Example #24
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         if (_target != null)
         {
             _target.Walk(walker);
         }
         if (_indexes != null)
         {
             foreach (var index in _indexes)
                 index.Walk(walker);
         }
     }
     walker.PostWalk(this);
 }
Example #25
0
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         if (_target != null)
         {
             _target.Walk(walker);
         }
         if (_args != null)
         {
             foreach (var arg in _args)
             {
                 arg.Walk(walker);
             }
         }
     }
     walker.PostWalk(this);
 }
 public override void Walk(Walker.TotemWalker walker)
 {
     if (walker.Walk(this))
     {
         if (_testExpr != null)
         {
             _testExpr.Walk(walker);
         }
         if (_trueExpr != null)
         {
             _trueExpr.Walk(walker);
         }
         if (_falseExpr != null)
         {
             _falseExpr.Walk(walker);
         }
     }
     walker.PostWalk(this);
 }
        void AnalyzeAssignment(SyntaxNodeAnalysisContext context, AssignmentExpressionSyntax assignment)
        {
            var containingMethod = assignment.GetContainingMethod();
            if (containingMethod.HasConstAttribute(context.SemanticModel)) {
                if (context.SemanticModel.GetSymbolInfo(assignment.Left).Symbol?.Kind == SymbolKind.Local) {
                    return;
                }

                var left = assignment.Left as MemberAccessExpressionSyntax;
                if (left != null) {
                    var walker = new Walker(context);
                    containingMethod.Accept(walker);
                    var exprSymbol = context.SemanticModel.GetSymbolInfo(left.Expression).Symbol;
                    if (exprSymbol != null && exprSymbol.Kind == SymbolKind.Local && !walker.UnsafeLocals.Contains(exprSymbol.Name)) {
                        return;
                    }
                }
                context.ReportDiagnostic(Diagnostic.Create(Rule, assignment.GetLocation(), context.SemanticModel.GetDeclaredSymbol(containingMethod)?.Name));
            }
        }
Example #28
0
        public virtual ValidationErrorCollection ValidateProperties(ValidationManager manager, object obj)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");
            if (obj == null)
                throw new ArgumentNullException("obj");

            ValidationErrorCollection errors = new ValidationErrorCollection();

            Activity activity = manager.Context[typeof(Activity)] as Activity;

            // Validate all members that support validations.
            Walker walker = new Walker(true);
            walker.FoundProperty += delegate(Walker w, WalkerEventArgs args)
            {
                //If we find dynamic property of the same name then we do not invoke the validator associated with the property
                //Attached dependency properties will not be found by FromName().

                // args.CurrentProperty can be null if the property is of type IList.  The walker would go into each item in the
                // list, but we don't need to validate these items.
                if (args.CurrentProperty != null)
                {
                    DependencyProperty dependencyProperty = DependencyProperty.FromName(args.CurrentProperty.Name, args.CurrentProperty.DeclaringType);
                    if (dependencyProperty == null)
                    {
                        object[] validationVisibilityAtrributes = args.CurrentProperty.GetCustomAttributes(typeof(ValidationOptionAttribute), true);
                        ValidationOption validationVisibility = (validationVisibilityAtrributes.Length > 0) ? ((ValidationOptionAttribute)validationVisibilityAtrributes[0]).ValidationOption : ValidationOption.Optional;
                        if (validationVisibility != ValidationOption.None)
                        {
                            errors.AddRange(ValidateProperty(args.CurrentProperty, args.CurrentPropertyOwner, args.CurrentValue, manager));
                            // don't probe into subproperties as validate object inside the ValidateProperties call does it for us
                            args.Action = WalkerAction.Skip;
                        }
                    }
                }
            };

            walker.WalkProperties(activity, obj);

            return errors;
        }
        public virtual void GenerateCode(CodeGenerationManager manager, object obj)
        {
            if (manager == null)
                throw new ArgumentNullException("manager");
            if (obj == null)
                throw new ArgumentNullException("obj");

            Activity activity = obj as Activity;
            if (activity == null)
                throw new ArgumentException(SR.GetString(SR.Error_UnexpectedArgumentType, typeof(Activity).FullName), "obj");

            manager.Context.Push(activity);

            // Generate code for all the member Binds.
            Walker walker = new Walker();
            walker.FoundProperty += delegate(Walker w, WalkerEventArgs args)
            {
                //
                ActivityBind bindBase = args.CurrentValue as ActivityBind;
                if (bindBase != null)
                {
                    // push
                    if (args.CurrentProperty != null)
                        manager.Context.Push(args.CurrentProperty);
                    manager.Context.Push(args.CurrentPropertyOwner);

                    // call generate code
                    foreach (ActivityCodeGenerator codeGenerator in manager.GetCodeGenerators(bindBase.GetType()))
                        codeGenerator.GenerateCode(manager, args.CurrentValue);

                    // pops
                    manager.Context.Pop();
                    if (args.CurrentProperty != null)
                        manager.Context.Pop();
                }
            };
            walker.WalkProperties(activity, obj);
            manager.Context.Pop();
        }
Example #30
0
        // GET: WalkersController/Delete/5
        public ActionResult Delete(int id)
        {
            Walker walker = _walkerRepo.GetWalkerById(id);

            return(View(walker));
        }
        private static IEnumerable <IdentifierReference> FindUnusedAssignmentReferences(Declaration localVariable, Walker walker)
        {
            if (!localVariable.References.Any(rf => rf.IsAssignment))
            {
                return(Enumerable.Empty <IdentifierReference>());
            }

            //Consider static local variables used if they are referenced anywhere within their procedure
            if (localVariable.References.Any(r => !r.IsAssignment) && IsStatic(localVariable))
            {
                return(Enumerable.Empty <IdentifierReference>());
            }

            var tree = walker.GenerateTree(localVariable.ParentScopeDeclaration.Context, localVariable);

            var allAssignmentsAndReferences = tree.Nodes(new[] { typeof(AssignmentNode), typeof(ReferenceNode) })
                                              .Where(node => localVariable.References.Contains(node.Reference))
                                              .ToList();

            var unusedAssignmentNodes = allAssignmentsAndReferences.Any(n => n is ReferenceNode)
                        ? FindUnusedAssignmentNodes(tree, localVariable, allAssignmentsAndReferences)
                        : allAssignmentsAndReferences.OfType <AssignmentNode>();

            return(unusedAssignmentNodes.Where(n => !IsDescendentOfNeverFlagNode(n))
                   .Select(n => n.Reference));
        }
Example #32
0
    private void CreateFloors()
    {
        // Loop won't run forever.
        int iterations = 0;

        do
        {
            if (walkers.Count > 0)
            {
                //GD.Print(RandomDirection().ToString());

                foreach (Walker walker in walkers)
                {
                    map[(int)walker.position.x, (int)walker.position.y] = Tile.Period;
                }

                // Chance walker gets destroyed
                int numberChecks = walkers.Count;
                for (int i = 0; i < numberChecks; i++)
                {
                    if (random.NextDouble() < chanceWalkerDestroy && walkers.Count > 1)
                    {
                        walkers.RemoveAt(i);
                        // Only destroy one per iteration.
                        break;
                    }
                }

                // Chance walker picks new direction
                for (int i = 0; i < walkers.Count; i++)
                {
                    if (random.NextDouble() < chanceWalkerDirection)
                    {
                        Walker walker = walkers[i];
                        walker.direction = RandomDirection();
                        walkers[i]       = walker;
                    }
                }

                // Chance new walker spawns
                for (int i = 0; i < walkers.Count; i++)
                {
                    if (random.NextDouble() < chanceWalkerSpawn && walkers.Count < maxWalkers)
                    {
                        Walker walker = new Walker();
                        walker.direction = RandomDirection();
                        walker.position  = walkers[i].position;
                        walkers.Add(walker);
                    }
                }

                // Move walkers.
                for (int i = 0; i < walkers.Count; i++)
                {
                    Walker walker = walkers[i];
                    //GD.Print("Previous position: " + walker.position.ToString());
                    walker.position += walker.direction;
                    //GD.Print("New position: " + walker.position.ToString());
                    walkers[i] = walker;
                }

                // Avoid border.
                for (int i = 0; i < walkers.Count; i++)
                {
                    Walker walker = walkers[i];
                    // Clamp x,y to leave a 1 space border -- leave room for walls.
                    walker.position.x = Mathf.Clamp(walker.position.x, 1, map.GetLength(0) - 2);
                    walker.position.y = Mathf.Clamp(walker.position.y, 1, map.GetLength(1) - 2);
                    walkers[i]        = walker;
                }

                // Check to exit loop.
                if ((float)NumberOfFloors() / (float)map.Length > percentToFill)
                {
                    break;
                }

                iterations++;
            }
        }while (iterations < 100000);
    }
Example #33
0
        private void Execute(int index, Translation translation, ref Condition condition, ref Walker walker)
        {
            if (condition.hunger < hungerLimit)
            {
                condition.isSet = false;
                return;
            }

            bool found = false;

            EdibleHashMap.MyData foundFood = new HashMapBase <Edible> .MyData();

            ForeachAround(translation.Value, condition, walker.direction, ref foundFood, ref found);

            if (found)
            {
                var length = math.length(foundFood.position - translation.Value);

                if (length < math.dot(math.normalizesafe(foundFood.position - translation.Value), walker.direction))
                {
                    walker.direction *= 0.9f;
                }

                FoundFood(translation, foundFood, index, ref walker, ref condition);
            }
            else
            {
                condition.isSet = false;
            }
        }
Example #34
0
        private void Execute(int index, Translation translation, FoodHierarchie hierarchie, ref Condition condition, ref Walker walker)
        {
            if (condition.hunger < hungerLimit)
            {
                condition.isSet = false;
                return;
            }

            var found     = false;
            var foundPrey = new FoodHierarchieHashMap.MyData();

            ForeachAround(translation.Value, condition, walker.direction, hierarchie, ref foundPrey, ref found);

            if (found)
            {
                var foundFood = new EdibleHashMap.MyData
                {
                    position = foundPrey.position,
                    data     = new Edible()
                    {
                        nutrition = foundPrey.data.nutrition,
                    },
                    entity = foundPrey.entity
                };
                FoundFood(translation, foundFood, index, ref walker, ref condition);
            }
            else
            {
                condition.isSet = false;
            }
        }
Example #35
0
        private void DereferenceCollection(CollectionType collectionType, bool implicitJoin, bool indexed, string classAlias)
        {
            _dereferenceType = DerefCollection;
            string role = collectionType.Role;

            //foo.bars.size (also handles deprecated stuff like foo.bars.maxelement for backwardness)
            IASTNode sibling        = NextSibling;
            bool     isSizeProperty = sibling != null && CollectionProperties.IsAnyCollectionProperty(sibling.Text);

            if (isSizeProperty)
            {
                indexed = true;                 //yuck!}
            }

            IQueryableCollection queryableCollection = SessionFactoryHelper.RequireQueryableCollection(role);
            string     propName          = Path;
            FromClause currentFromClause = Walker.CurrentFromClause;

            if (Walker.StatementType != HqlSqlWalker.SELECT && indexed && classAlias == null)
            {
                // should indicate that we are processing an INSERT/UPDATE/DELETE
                // query with a subquery implied via a collection property
                // function. Here, we need to use the table name itself as the
                // qualification alias.
                // TODO : verify this works for all databases...
                // TODO : is this also the case in non-"indexed" scenarios?
                string alias = GetLhs().FromElement.Queryable.TableName;
                _columns = FromElement.ToColumns(alias, _propertyPath, false, true);
            }

            //We do not look for an existing join on the same path, because
            //it makes sense to join twice on the same collection role
            var factory = new FromElementFactory(
                currentFromClause,
                GetLhs().FromElement,
                propName,
                classAlias,
                GetColumns(),
                implicitJoin
                );
            FromElement elem = factory.CreateCollection(queryableCollection, role, _joinType, _fetch, indexed);

            if (Log.IsDebugEnabled())
            {
                Log.Debug("dereferenceCollection() : Created new FROM element for {0} : {1}", propName, elem);
            }

            SetImpliedJoin(elem);
            FromElement = elem;                 // This 'dot' expression now refers to the resulting from element.

            if (isSizeProperty)
            {
                elem.Text             = "";
                elem.UseWhereFragment = false;
            }

            if (!implicitJoin)
            {
                IEntityPersister entityPersister = elem.EntityPersister;
                if (entityPersister != null)
                {
                    Walker.AddQuerySpaces(entityPersister.QuerySpaces);
                }
            }
            Walker.AddQuerySpaces(queryableCollection.CollectionSpaces);                // Always add the collection's query spaces.
        }
Example #36
0
        private void DereferenceEntityJoin(string classAlias, EntityType propertyType, bool impliedJoin, IASTNode parent)
        {
            _dereferenceType = DerefEntity;
            if (Log.IsDebugEnabled())
            {
                Log.Debug("dereferenceEntityJoin() : generating join for {0} in {1} {2} parent = {3}",
                          _propertyName,
                          FromElement.ClassName,
                          ((classAlias == null) ? "{no alias}" : "(" + classAlias + ")"),
                          ASTUtil.GetDebugstring(parent));
            }

            // Create a new FROM node for the referenced class.
            string associatedEntityName = propertyType.GetAssociatedEntityName();
            string tableAlias           = AliasGenerator.CreateName(associatedEntityName);

            string[] joinColumns = GetColumns();
            string   joinPath    = Path;

            if (impliedJoin && Walker.IsInFrom)
            {
                _joinType = Walker.ImpliedJoinType;
            }

            FromClause  currentFromClause = Walker.CurrentFromClause;
            FromElement elem = currentFromClause.FindJoinByPath(joinPath);

            ///////////////////////////////////////////////////////////////////////////////
            //
            // This is the piece which recognizes the condition where an implicit join path
            // resolved earlier in a correlated subquery is now being referenced in the
            // outer query.  For 3.0final, we just let this generate a second join (which
            // is exactly how the old parser handles this).  Eventually we need to add this
            // logic back in and complete the logic in FromClause.promoteJoin; however,
            // FromClause.promoteJoin has its own difficulties (see the comments in
            // FromClause.promoteJoin).
            //
            //		if ( elem == null ) {
            //			// see if this joinPath has been used in a "child" FromClause, and if so
            //			// promote that element to the outer query
            //			FromClause currentNodeOwner = getFromElement().getFromClause();
            //			FromClause currentJoinOwner = currentNodeOwner.locateChildFromClauseWithJoinByPath( joinPath );
            //			if ( currentJoinOwner != null && currentNodeOwner != currentJoinOwner ) {
            //				elem = currentJoinOwner.findJoinByPathLocal( joinPath );
            //				if ( elem != null ) {
            //					currentFromClause.promoteJoin( elem );
            //					// EARLY EXIT!!!
            //					return;
            //				}
            //			}
            //		}
            //
            ///////////////////////////////////////////////////////////////////////////////

            // even though we might find a pre-existing element by join path, we may not be able to reuse it...
            bool useFoundFromElement = elem != null && CanReuse(classAlias, elem);

            if (!useFoundFromElement)
            {
                // If this is an implied join in a from element, then use the impled join type which is part of the
                // tree parser's state (set by the gramamar actions).
                JoinSequence joinSequence = SessionFactoryHelper
                                            .CreateJoinSequence(impliedJoin, propertyType, tableAlias, _joinType, joinColumns);

                var factory = new FromElementFactory(
                    currentFromClause,
                    GetLhs().FromElement,
                    joinPath,
                    classAlias,
                    joinColumns,
                    impliedJoin
                    );
                elem = factory.CreateEntityJoin(
                    associatedEntityName,
                    tableAlias,
                    joinSequence,
                    _fetch,
                    Walker.IsInFrom,
                    propertyType
                    );
            }
            else
            {
                currentFromClause.AddDuplicateAlias(classAlias, elem);
            }

            SetImpliedJoin(elem);
            Walker.AddQuerySpaces(elem.EntityPersister.QuerySpaces);
            FromElement = elem;                 // This 'dot' expression now refers to the resulting from element.
        }
Example #37
0
 void Start()
 {
     walker = GetComponent <Walker>();
     playerAttackManager = GetComponent <PlayerAttackManager>();
     manaMode            = GetComponent <ManaMode>();
 }
 public override void _Ready()
 {
     walker = new Walker();
     walker.SetXY(GetViewportRect().Size / 2);
     AddChild(walker);
 }
Example #39
0
        static void Main(string[] args)
        {
            while (true)
            {
                Console.WriteLine("");
                Console.WriteLine("What would you like to do?");
                Console.WriteLine("");

                Console.WriteLine("1. Show all dog  walkers");
                Console.WriteLine("2. Show all dog walkers for a specific neighborhood");
                Console.WriteLine("3. Add a new dog walker");
                Console.WriteLine("4. Show all owners");
                Console.WriteLine("5. Add a new owner");
                Console.WriteLine("6. Update owner's neighborhood");
                Console.WriteLine("");

                var choice = Console.ReadLine();
                WalkerRepository       walkerRepo       = new WalkerRepository();
                OwnerRepository        ownerRepo        = new OwnerRepository();
                NeighborhoodRepository neighborhoodRepo = new NeighborhoodRepository();

                switch (Int32.Parse(choice))
                {
                case 1:
                    Console.WriteLine("All dog walkers:");
                    Console.WriteLine("");
                    List <Walker> allWalkers = walkerRepo.GetAllWalkers();
                    foreach (Walker walker in allWalkers)
                    {
                        Console.WriteLine($"{walker.Name}");
                    }
                    break;

                case 2:
                    Console.WriteLine("Enter the neighborhood Id");
                    var neighborhoodChoice = int.Parse(Console.ReadLine());
                    Console.WriteLine($"Getting walkers with a neighborhood Id of {neighborhoodChoice}");
                    List <Walker> neighborhoodWalkerList = walkerRepo.GetAllWalkersByNeighborhoodId(neighborhoodChoice);

                    foreach (var walker in neighborhoodWalkerList)
                    {
                        Console.WriteLine($"{walker.Name} - {walker.Neighborhood.Name} ");
                    }
                    break;

                case 3:
                    Console.WriteLine("Enter the name of the new dog walker");
                    var walkerName = Console.ReadLine();
                    Console.WriteLine("Enter the new dog walker's neighborhood Id");
                    var    walkerNeighborhoodId = Int32.Parse(Console.ReadLine());
                    Walker newWalker            = new Walker
                    {
                        Name           = walkerName,
                        NeighborhoodId = walkerNeighborhoodId
                    };
                    walkerRepo.AddWalker(newWalker);
                    Console.WriteLine($"Added {newWalker.Name} as a new dog walker!");
                    break;

                case 4:
                    List <Owner> allOwners = ownerRepo.GetAllOwners();
                    Console.WriteLine("All owners:");

                    foreach (Owner owner in allOwners)
                    {
                        Console.WriteLine($"{owner.Name} - {owner.Neighborhood.Name}");
                    }
                    break;

                case 5:
                    Console.WriteLine("Enter new owner's name");
                    var newOwnerName = Console.ReadLine();
                    Console.WriteLine("Enter the number of the neighborhood the owner belongs to");
                    List <Neighborhood> allNeighborhoods = neighborhoodRepo.GetAllNeighborhoods();

                    foreach (Neighborhood n in allNeighborhoods)
                    {
                        Console.WriteLine($"{n.Id}. {n.Name}");
                    }

                    var newOwnerNId = int.Parse(Console.ReadLine());
                    Console.WriteLine("Enter the new owner's phone number");
                    var newOwnerPhone = Console.ReadLine();

                    Console.WriteLine("Enter the new owner's address");
                    var newOwnerAddress = Console.ReadLine();

                    Owner newOwner = new Owner
                    {
                        Name           = newOwnerName,
                        NeighborhoodId = newOwnerNId,
                        Phone          = newOwnerPhone,
                        Address        = newOwnerAddress
                    };

                    ownerRepo.AddOwner(newOwner);
                    Console.WriteLine($"Added {newOwnerName} as a new owner!");
                    break;

                case 6:
                    Console.WriteLine("Which owner would you like to update?");
                    List <Owner> allOwnersToUpdate = ownerRepo.GetAllOwners();
                    foreach (Owner owner in allOwnersToUpdate)
                    {
                        Console.WriteLine($"{owner.Id}. {owner.Name} - {owner.Neighborhood.Name}");
                    }

                    var chosenOwnerToUpdate = Int32.Parse(Console.ReadLine());
                    var selectedOwner       = ownerRepo.GetOwnerById(chosenOwnerToUpdate);

                    Console.WriteLine("Enter the number of the neighborhood you change the owner to");
                    List <Neighborhood> allPossibleNeighborhoods = neighborhoodRepo.GetAllNeighborhoods();

                    foreach (Neighborhood n in allPossibleNeighborhoods)
                    {
                        Console.WriteLine($"{n.Id}. {n.Name}");
                    }

                    var updateOwnerNId = int.Parse(Console.ReadLine());
                    selectedOwner.NeighborhoodId = updateOwnerNId;

                    ownerRepo.UpdateOwner(selectedOwner.Id, selectedOwner);
                    Console.WriteLine($"{selectedOwner.Name}'s neighborhood has been updated to {selectedOwner.Neighborhood.Name}");
                    break;
                }
            }
        }
 public AssignmentNotUsedInspection(IDeclarationFinderProvider declarationFinderProvider, Walker walker)
     : base(declarationFinderProvider)
 {
     _walker = walker;
 }
Example #41
0
        // GET: Walkers/Create
        public ActionResult Create()
        {
            Walker walker = new Walker();

            return(View(walker));
        }
Example #42
0
 protected void Start()
 {
     m_Camera = Camera.main;
     m_Walker = GetComponent <Walker>();
 }
 void Walker_OnWalkerDied(Walker e)
 {
     // Если этого не сделать, видимо walker пугается
 }
Example #44
0
        public Call(string filename)
        {
            Name = Walker.PureName(filename);
            if (Name.Length > 6 && Char.IsDigit(Name[Name.Length - 1]) && Char.IsDigit(Name[Name.Length - 2]) && Char.IsDigit(Name[Name.Length - 3]) && Char.IsDigit(Name[Name.Length - 4]) && Name[Name.Length - 5] == '-')
            {
                ReadableName = Name.Substring(0, Name.LastIndexOf('-')) + " " + Name.Substring(Name.Length - 4);
            }
            else
            {
                ReadableName = Name;
            }

            var lines = File.ReadAllLines(filename);

            foreach (var rawline in lines)
            {
                var line    = rawline.Trim();
                var addline = rawline;
                if (String.IsNullOrEmpty(line))
                {
                    Content += rawline;
                    continue;
                }
                if (new HashSet <char>(line.ToCharArray()).Count == 1 && (line[0] == '-' || line[0] == '='))
                {
                    Content += "<hr/><br/>" + Environment.NewLine;
                    continue;
                }
                if (addline.StartsWith("  ", StringComparison.Ordinal))
                {
                    int i = 0;
                    while (i < addline.Length && addline[i] == ' ')
                    {
                        i++;
                    }
                    addline = Fancy.Times("&nbsp;", i) + addline.TrimStart();
                }
                if (line.StartsWith("###", StringComparison.Ordinal))
                {
                    addline = Fancy.ReplaceFirst(addline, "###", "<h3>") + "</h3>";
                }
                if (line.Contains("**"))
                {
                    while (addline.Contains("**"))
                    {
                        addline = Fancy.ReplaceFirst(addline, "**", "<b>");
                        addline = Fancy.ReplaceFirst(addline, "**", "</b>");
                    }
                }
                if (addline[0] == '*')
                {
                    addline = '•' + addline.Substring(1);
                }
                Content += addline + "<br/>";
            }
            while (Content.Contains("[["))
            {
                int beg = Content.IndexOf("[[", StringComparison.Ordinal);
                int end = Content.IndexOf("]]", StringComparison.Ordinal);
                if (beg < 0 || end < 0 || end < beg)
                {
                    Logger.Log($"Call '{filename}' broken w.r.t. metabrackets");
                    return;
                }
                string before = Content.Substring(0, beg);
                string inside = Content.Substring(beg + 2, end - beg - 2);
                string after = Content.Substring(end + 2);
                string target, text;
                var    split = inside.Split('|');
                if (split.Length == 1)
                {
                    target = inside;
                    text   = inside;
                }
                else if (split.Length == 2)
                {
                    target = split[0];
                    text   = split[1];
                }
                else
                {
                    Logger.Log($"Call '{filename}' broken w.r.t. pipelines");
                    return;
                }

                target = target.Replace('\n', ' ').Replace('\r', ' ').Replace('\t', ' ').Replace("<br/>", " ").Replace("  ", " ");

                // [[X]]s
                while (after.Length > 0 && Char.IsLetter(after[0]))
                {
                    text += after[0];
                    after = after.Substring(1);
                }

                // linkification
                if (String.IsNullOrEmpty(target) || String.IsNullOrEmpty(text))
                {
                    Logger.Log($"Call '{filename}' broken w.r.t. metalinks");
                    return;
                }

                if (target.StartsWith("http", StringComparison.Ordinal))
                {
                    inside = $"<a href=\"{target}\">{text}</a>";
                }
                else if (target[0] == '@')
                {
                    target = target.Substring(1);
                    if (text[0] == '@')
                    {
                        text = text.Substring(1);
                    }
                    inside = $"<a href=\"../person/{Fancy.DeUmlautify(target.Replace(' ', '_'))}.html\">{text}</a>";
                }
                else if (target[0] == '#')
                {
                    target = target.Substring(1).ToLower();
                    if (text[0] == '#')
                    {
                        text = text.Substring(1);
                    }
                    inside = $"<a href=\"../tag/{target}.html\">{text}</a>";
                }
                else
                {
                    inside = $"<a href=\"../{target}.html\">{text}</a>";
                    //Logger.Log($"Call '{filename}' contvains unintelligible metabracket '{inside}'");
                }

                // get it back together
                Content = before + inside + after;
            }
        }
Example #45
0
 private void Start()
 {
     walker = GetComponent <Walker>();
 }
Example #46
0
 public TWalkToTarget(Walker self, float safeDis, List<Entity> targetTpye) : base(self, "T_WalkToTarget") {
     Self = self;
     SafeDis = safeDis;
     TargetTpye = targetTpye;
 }
Example #47
0
        public override void VisitPaper(Paper paper)
        {
            if (String.IsNullOrEmpty(paper.title))
            {
                return;
            }
            if (!paper.title.EndsWith(")", StringComparison.InvariantCulture))
            {
                return;
            }
            int index = paper.title.LastIndexOf('(');

            // should never happen, but you never know
            if (index == 0 || paper.title[index - 1] != ' ')
            {
                return;
            }
            string main = paper.title.Substring(0, index).Trim();
            string brak = paper.title.Substring(index + 1);

            // get rid of the bracket
            brak = brak.Substring(0, brak.Length - 1).Trim();
            Xformation action;

            switch (brak.ToLower())
            {
            case "s":     // happens in SEKE (probably corrupt metadata)
            case "full paper":
                action = new XPaper(GenPaperAction(main));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "abstract":
            case "abstract for talk":
            case "abstract only":
            case "talk abstract":
            case "detailed abstract":
            case "extended abstract":
            case "extended abstracts":
            case "extende abstract":     // misspelling!
            case "extended summary":
            case "research summary":
            case "extended outline":
            case "summary":
            case "summaray":     // misspelling!
            case "a summary":
            case "concise version":
                action = new XPaper(GenPaperAction(main, "abstract"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "best paper":
            case "best paper award":
            case "awarded best paper!":
                action = new XPaper(GenPaperAction(main, "best paper"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "an experience report":
            case "experience report":
            case "experience paper":
            case "status report":
            case "partial report":
                action = new XPaper(GenPaperAction(main, "report"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "keynote":
            case "abstract of keynote address":
            case "keynote abstract":
            case "keynote address — abstract":
            case "keynote address":
            case "keynote paper":
            case "keynote talk":
            case "seip keynote":     // special case
                action = new XPaper(GenPaperAction(main, "keynote"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "industrial session":
            case "industrial paper":
            case "industrial talk":
                action = new XPaper(GenPaperAction(main, "industrial"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "invited industrial talk":
                action = new XPaper(GenPaperAction(main, "industrial", "invited"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "invited lecture":
            case "invited paper":
            case "invited presentation":
            case "invited talk":
                action = new XPaper(GenPaperAction(main, "invited"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "abstract of invited tutorial":
                action = new XPaper(GenPaperAction(main, "abstract", "invited", "tutorial"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "invited tutorial":
                action = new XPaper(GenPaperAction(main, "invited", "tutorial"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "tutorial/keynote":
                action = new XPaper(GenPaperAction(main, "keynote", "tutorial"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "invited talk abstract":
            case "invited talk, abstract only":
            case "abstract of an invited lecture":
            case "abstract of invited lecture":
            case "abstract of invited presentation":
            case "abstract of invited talk":
            case "extended abstract of invited talk":
                action = new XPaper(GenPaperAction(main, "invited", "abstract"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "tutorial overview":
            case "tutorial abstract":
            case "abstract of a tutorial":
            case "extended abstract of a tutorial":
                action = new XPaper(GenPaperAction(main, "tutorial", "abstract"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "short paper":
            case "short version":
                action = new XPaper(GenPaperAction(main, "short"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "system descrition":     // misspelling!
            case "system description":
            case "system descriptions":
            case "system exhibition":
                action = new XPaper(GenPaperAction(main, "system description"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "tool":
            case "tool demo":
            case "tool demonstration":
            case "tool paper":
            case "tool presentation":
                action = new XPaper(GenPaperAction(main, "tool"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "demo abstract":
                action = new XPaper(GenPaperAction(main, "tool", "abstract"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "mini-tutorial":
            case "distilled tutorial":
            case "a tutorial":
            case "tutorial":
            case "tutorial session":
                action = new XPaper(GenPaperAction(main, "tutorial"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "position statement":
            case "position paper":
            case "vision paper":
                action = new XPaper(GenPaperAction(main, "vision"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "functional pearl":
            case "declarative pearl":
                action = new XPaper(GenPaperAction(main, "pearl"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "a preliminary report":
            case "preliminary report":
            case "preliminary draft":
            case "preliminary version":
            case "work in progress":
            case "working paper":
                action = new XPaper(GenPaperAction(main, "work in progress"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "preliminary abstract":
            case "preliminary extended abstract":
                action = new XPaper(GenPaperAction(main, "abstract", "work in progress"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            case "system abstract":
                action = new XPaper(GenPaperAction(main, "abstract", "system description"));
                Manager.RegisterAction(ACTION_NAME, paper, action);
                break;

            default:
                Logger.Log($"Paper '{Walker.PureName(paper)}' has a strange potential status: '({brak})'");
                break;
            }
        }
Example #48
0
 public override void BuildingDestroyed(IBuilding building, ITile tile)
 {
     Walker.Stop();
     Unit.MoveTo(Unit.Position.WithY(Level.Map.GetTerrainHeightAt(Unit.Position.XZ2())));
 }
Example #49
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButton(0) && ready2hit)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                hit_pos = hit.point;
                God_Attack(); print(hit_pos);
                Reduce_Score(RAGE_COST); ready2hit = false;
            }
        }
        if (factory.tower.Is_Dead())
        {
            if (!view.is_Game_Over_set())
            {
                view.add_soldier.onClick.RemoveListener(Add_Soldier);
                view.add_barrier.onClick.RemoveListener(Add_Barrier);
                view.add_outpost.onClick.RemoveListener(Add_Outpost);
                view.god_cure.onClick.RemoveListener(God_Cure);
                view.god_rage.onClick.RemoveListener(God_Rage);
                Game_Over();
            }
            return;
        }

        view.Set_Soldier_Button_Color(player_score >= Soldier.Get_COST());
        view.Set_Barrier_Button_Color(player_score >= Barrier.Get_COST());
        view.Set_Outpost_Button_Color(player_score >= Outpost.Get_COST());
        view.Set_Cure_Button_Color(player_score >= CURE_COST);
        view.Set_Rage_Button_Color(player_score >= RAGE_COST);
        view.Set_Score_Text(player_score);
        view.Set_Time_Text(Time.time);
        view.Set_Tower_Text(factory.tower.Get_DEF());
        view.Set_Statistic_Text(factory.soldiers.Count, factory.barriers.Count, factory.outposts.Count, factory.walkers.Count, factory.flyers.Count, game_level);

        int cur_level = Mathf.FloorToInt(player_score / 1000);

        if (cur_level > game_level)
        {
            game_level = cur_level;
            Go_Harder();
        }
        if (Time.time - generate_walker_timer > generate_walker_interval)
        {
            Walker new_walker = factory.Generate_Walker();
            Set_Nav(new_walker, factory.tower);
            generate_walker_timer = Time.time;
        }
        if (Time.time - generate_flyer_timer > generate_flyer_interval)
        {
            Flyer new_flyer = factory.Generate_Flyer();
            Set_Nav(new_flyer, factory.tower);
            generate_flyer_timer = Time.time;
        }

        Tower_Attack_Flyers();
        Tower_Attack_Walkers();
        Soldiers_Attack_Walkers();
        Barriers_Attack_Walkers();
        Outposts_Attack_Flyers();
        Outposts_Attack_Walkers();
        Walkers_Attack_Tower();
        Walkers_Attack_Soldiers();
        Walkers_Attack_Barriers();
        Flyers_Attack_Outposts();
        Flyers_Attack_Tower();
        Flyers_Attack_Barriers();
    }
Example #50
0
 IEnumerable <Waypoint> MovingRangeTarget.IUser.GetFutureWaypoints(MovingRangeTarget movingRangeTarget)
 {
     return(Walker.GetRestOfThePath(new Vector3(0, 0.5f, 0)));
 }
Example #51
0
 private void FoundFood(Translation translation, EdibleHashMap.MyData foundFood, int index, ref Walker walker, ref Condition condition)
 {
     if (IsInRadius(translation.Value, condition.eatingRadius, condition.viewAngle, walker.direction, foundFood.position))
     {
         commandBuffer.DestroyEntity(index, foundFood.entity);
         condition.hunger -= foundFood.data.nutrition;
         if (condition.hunger < 0)
         {
             condition.hunger = 0;
         }
         condition.isSet = false;
         return;
     }
     else
     {
         condition.goal  = foundFood.position;
         condition.isSet = true;
     }
 }
Example #52
0
 public AssignmentNotUsedInspection(RubberduckParserState state, Walker walker)
     : base(state)
 {
     _walker = walker;
 }
Example #53
0
 void Awake()
 {
     walker = GetComponentInParent <Walker>();
 }
Example #54
0
        public async Task <IActionResult> Get(
            [FromRoute] int id,
            [FromQuery] string include)
        {
            using (SqlConnection conn = Connection)
            {
                conn.Open();
                using (SqlCommand cmd = conn.CreateCommand())
                {
                    cmd.CommandText = @"
                        SELECT wr.Id, wr.Name, wr.NeighborhoodId ";

                    if (include == "walks")
                    {
                        cmd.CommandText += ", ws.Id AS WalksId, ws.Date, ws.Duration, ws.WalkerId, ws.DogId ";
                    }

                    cmd.CommandText += "FROM Walker wr ";

                    if (include == "walks")
                    {
                        cmd.CommandText += "LEFT JOIN Walks ws ON wr.id = ws.WalkerId ";
                    }

                    cmd.CommandText += "WHERE wr.Id = @id";

                    cmd.Parameters.Add(new SqlParameter("@id", id));

                    SqlDataReader reader = cmd.ExecuteReader();

                    Walker walker = null;

                    while (reader.Read())
                    {
                        if (walker == null)
                        {
                            walker = new Walker
                            {
                                Id             = reader.GetInt32(reader.GetOrdinal("Id")),
                                Name           = reader.GetString(reader.GetOrdinal("Name")),
                                NeighborhoodId = reader.GetInt32(reader.GetOrdinal("NeighborhoodId")),
                                Walks          = new List <Walks>()
                            };
                        }

                        if (include == "walks")
                        {
                            walker.Walks.Add(new Walks()
                            {
                                Id       = reader.GetInt32(reader.GetOrdinal("WalksId")),
                                Date     = reader.GetDateTime(reader.GetOrdinal("Date")),
                                Duration = reader.GetInt32(reader.GetOrdinal("Duration")),
                                WalkerId = reader.GetInt32(reader.GetOrdinal("WalkerId")),
                                DogId    = reader.GetInt32(reader.GetOrdinal("WalkerId"))
                            });
                        }
                    }
                    reader.Close();

                    return(Ok(walker));
                }
            }
        }
Example #55
0
    public static bool ClimbToTarget(ref Entity.CtrlInput input, Climber self, Walker target, float safeDis)
    {
        int selfFloor   = GlobalVar.Mask.GetFloor(self.gameObject.layer);
        int targetFloor = GlobalVar.Mask.GetFloor(target.gameObject.layer);

        Vector2 selfPos   = self.transform.position;
        Vector2?targetPos = target.transform.position;

        GameCtrl.Ladder?TargetLadder = null;

        if (target.GetState() == GlobalVar.State.Climb)
        {
            return(false);
        }
        if (selfFloor == targetFloor)
        {
            if ((selfPos - (Vector2)targetPos).magnitude < safeDis)
            {
                targetPos = null;
            }
        }
        else
        {
            bool upDown = selfFloor < targetFloor;
            if (self.OnLadder)
            {
                GameCtrl.Ladder ladder = self.Ladder;
                if (self.GetState() == GlobalVar.State.Climb)
                {
                    input.UpDnAxis = selfPos.y < (upDown ? ladder.UpPos.position.y : ladder.DownPos.position.y) ? 1 : -1;
                }
                else
                {
                    targetPos = upDown ? ladder.UpPos.position : ladder.DownPos.position;
                }
            }
            else
            {
                if (target.OnLadder && Mathf.Abs(selfFloor - targetFloor) == 1)
                {
                    if ((selfPos - (Vector2)targetPos).magnitude < safeDis)
                    {
                        targetPos = null;
                    }
                    else
                    {
                        TargetLadder = target.Ladder;
                    }
                }
                else
                {
                    foreach (GameCtrl.Ladder ladder in GameCtrl.LadderList)
                    {
                        if (upDown ? ladder.DownFloor == selfFloor : ladder.UpFloor == selfFloor)
                        {
                            if (TargetLadder == null ||
                                Mathf.Abs(selfPos.x - (upDown ? ladder.DownPos.position.x : ladder.UpPos.position.x)) <
                                Mathf.Abs(selfPos.x - (upDown
                                                 ? ((GameCtrl.Ladder)TargetLadder).DownPos.position.x
                                                 : ((GameCtrl.Ladder)TargetLadder).UpPos.position.x)))
                            {
                                TargetLadder = ladder;
                            }
                        }
                    }
                }

                if (TargetLadder != null)
                {
                    targetPos = upDown
                    ? ((GameCtrl.Ladder)TargetLadder).DownPos.position
                    : ((GameCtrl.Ladder)TargetLadder).UpPos.position;
                    if (((Vector2)targetPos - selfPos).magnitude < 0.1f)
                    {
                        input.UpDnAxis = upDown ? 1 : -1;
                    }
                }
            }
        }

        if (targetPos != null)
        {
            input.MoveAxis = (TargetLadder != null && ((GameCtrl.Ladder)TargetLadder).AngleType == 0?Mathf.Clamp(Mathf.Abs(selfPos.x - ((Vector2)targetPos).x) * 0.3f, 0.25f, 1):1) * (selfPos.x < ((Vector2)targetPos).x ? 1 : -1);
            return(true);
        }
        return(false);
    }
Example #56
0
 private void Awake()
 {
     _steer  = new Steer(_directions_count);
     _walker = GetComponent <Walker>();
     _looker = GetComponent <Looker>();
 }
Example #57
0
 private Vector2Int GetNextPosition(Walker walker)
 {
     return(WalkerPositionToGridPosition(walker.Position + (GridToWorldConversion * walker.Direction)));
 }
Example #58
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        int floorLevel = Global.floorLevel;

        Global.state = "game";



        for (int i = 0; i < 200; i++)
        {
            tileArray.Add(new List <AStarSharp.Node>());

            for (int j = 0; j < 200; j++)
            {
                tileArray[i].Add(new AStarSharp.Node(new Vector2(i, j), false));
            }
        }

        for (int i = -70; i < 200; i++)
        {
            for (int j = -70; j < 200; j++)
            {
                SetCell(i, j, 0);
            }
        }

        //ROOM LAYOUT

        int[,] dungeonRoomGrid = new int[mapSize * 2 + 1, mapSize * 2 + 1];

        int noOfWalkers = (int)Math.Floor(floorLevel / 3f) + 3;

        //GD.Print(noOfWalkers);
        //GD.Print((int)((1f / (floorLevel + 3)) * 100));
        Walker[] walkerArray = new Walker[noOfWalkers];

        for (int i = 0; i < walkerArray.Length; i++)
        {
            walkerArray[i] = new Walker();
        }

        //for(int i=0;i<30;i++)
        //{ GD.Print(i+" chance=" +
        //	((50f / 900f) * i * i - (3000f / 900f) * i + 50)); }

        float chance = ((50f / 900f) * floorLevel * floorLevel - (3000f / 900f) * floorLevel + 50);

        while (true)
        {
            bool flag = true;

            for (int i = 0; i < noOfWalkers; i++)
            {
                if (walkerArray[i].alive)
                {
                    flag = false;
                    //attempt to kill the walker. chance decreases per floor level
                    bool result = walkerArray[i].stillAlive(chance, floorLevel);

                    //if it was killed make the current room a treasure room
                    if (result)
                    {
                        walkerArray[i].killX = walkerArray[i].x;
                        walkerArray[i].killY = walkerArray[i].y;
                    }
                    else
                    {
                        dungeonRoomGrid[walkerArray[i].x + (mapSize - 1), walkerArray[i].y + (mapSize - 1)] = 1;
                        walkerArray[i].move(mapSize);
                    }
                }
            }
            if (flag)
            {
                break;
            }
        }

        for (int i = 0; i < noOfWalkers; i++)
        {
            dungeonRoomGrid[walkerArray[i].killX + (mapSize - 1), walkerArray[i].killY + (mapSize - 1)] = 2;
        }

        //make the starter room a default room
        dungeonRoomGrid[(mapSize - 1), (mapSize - 1)] = 3;

        for (int i = 0; i < 9; i++)
        {
            for (int j = 0; j < 9; j++)
            {
                //GD.PrintRaw(dungeonRoomGrid[i, j]);
            }
            //GD.Print("");
        }

        //POPULATE MAP WITH ROOMS

        RoomGen roomGen = new RoomGen();

        int[][] roomHolder = new int[11][];         //structure to hold data for room, room size 11
        for (int i = 0; i < roomHolder.Length; i++)
        {
            roomHolder[i] = new int[11];
        }


        for (int i = 0; i < (mapSize * 2) + 1; i++)
        {
            for (int j = 0; j < (mapSize * 2) + 1; j++)
            {
                switch (dungeonRoomGrid[i, j])
                {
                case 0:
                    break;

                //main
                case 1:
                    roomHolder = roomGen.randomRoom(1);
                    updateTileMapWRoom(ref roomHolder, i, j);
                    break;

                //treasure
                case 2:
                    roomHolder = roomGen.randomRoom(2);
                    updateTileMapWRoom(ref roomHolder, i, j);
                    break;

                case 3:
                    roomHolder = roomGen.randomRoom(3);
                    updateTileMapWRoom(ref roomHolder, i, j);
                    break;
                }
            }
        }

        //CREATE DOORS

        //For each room check if there is room below it and to the right of it
        for (int i = 0; i < (mapSize * 2) + 1; i++)
        {
            for (int j = 0; j < (mapSize * 2) + 1; j++)
            {
                if (!(dungeonRoomGrid[i, j] == 0))
                {
                    //carve out door
                    if (!(dungeonRoomGrid[i + 1, j] == 0))
                    {
                        //create a door width
                        int rand = (int)Math.Round(GD.RandRange(0.5, 5.49));

                        for (int k = rand; k < 11 - rand; k++)
                        {
                            tileArray[10 + 11 * i][k + 11 * j] = new AStarSharp.Node(new Vector2(10 + 11 * i, k + 11 * j), true);
                            tileArray[11 + 11 * i][k + 11 * j] = new AStarSharp.Node(new Vector2(11 + 11 * i, k + 11 * j), true);
                            SetCell(10 + 11 * i, k + 11 * j, 1);
                            SetCell(11 + 11 * i, k + 11 * j, 1);
                        }
                    }

                    if (!(dungeonRoomGrid[i, j + 1] == 0))
                    {
                        //create a door width
                        int rand = (int)Math.Round(GD.RandRange(0.5, 5.49));

                        for (int k = rand; k < 11 - rand; k++)
                        {
                            tileArray[k + 11 * i][10 + 11 * j] = new AStarSharp.Node(new Vector2(k + 11 * i, 10 + 11 * j), true);
                            tileArray[k + 11 * i][11 + 11 * j] = new AStarSharp.Node(new Vector2(k + 11 * i, 11 + 11 * j), true);

                            SetCell(k + 11 * i, 10 + 11 * j, 1);
                            SetCell(k + 11 * i, 11 + 11 * j, 1);
                        }
                    }
                }
            }
        }

        pathfindAstar = new AStarSharp.Astar(tileArray);

        UpdateBitmaskRegion();
        for (int i = 0; i < 200; i++)
        {
            for (int j = 0; j < 200; j++)
            {
                if (tileArray[i][j].Walkable)
                {                // GD.PrintRaw(0);
                }
                else             //GD.PrintRaw(1);
                {
                }
            }
            //GD.Print("");
        }
        var scene = GD.Load <PackedScene>("res://CardAndSpawnManager.tscn");

        var node = scene.Instance();

        AddChild(node);
    }
Example #59
0
    /*
** This routine adds datatype and collating sequence information to
** the Table ures of all FROM-clause subqueries in a
** SELECT statement.
**
** Use this routine after name resolution.
*/
    static void sqlite3SelectAddTypeInfo( Parse pParse, Select pSelect )
    {
#if !SQLITE_OMIT_SUBQUERY
      Walker w = new Walker();
      w.xSelectCallback = selectAddSubqueryTypeInfo;
      w.xExprCallback = exprWalkNoop;
      w.pParse = pParse;
      sqlite3WalkSelect( w, pSelect );
#endif
    }
    public void SpawnCaravan(ItemOrder co)
    {
        bool import = co.direction == TradeDirection.Import;

        //check if map entrance
        Structure mapEntrance = GameObject.FindGameObjectWithTag("MapEntrance").GetComponent <Structure>();

        if (mapEntrance == null)
        {
            Debug.LogError("No map entrance for caravan found");
        }

        //make queue of storage buildings
        SimplePriorityQueue <StorageBuilding> queue = import ?
                                                      mapEntrance.FindStorageBuildingToAccept(co) :
                                                      mapEntrance.FindStorageBuildingThatHas(co);

        for (int i = 0; queue.Count > 0 && i < 5; i++)
        {
            Node start = new Node(mapEntrance);

            //pop storage building, make sure it has an exit
            Structure   strg  = queue.Dequeue();
            List <Node> exits = strg.GetAdjRoadTiles();
            if (exits.Count == 0)
            {
                continue;
            }

            //find a path, continue only if it exists
            string       caravanName = import ? "Importer" : "Exporter";
            Queue <Node> path        = new Pathfinder(worldController.Map).FindPath(start, exits, caravanName);
            if (path.Count == 0)
            {
                continue;
            }

            GameObject go = worldController.SpawnObject("Walkers", caravanName, start);

            Walker w = go.GetComponent <Walker>();
            w.Order       = co;
            w.world       = worldController;
            w.Origin      = mapEntrance;
            w.Destination = strg;
            w.SetPath(path);
            w.Activate();
            break;
        }

        //List<Node> entrances = target.GetAdjRoadTiles();
        //if (entrances.Count == 0)
        //	return;

        //Node start = new Node(mapEntrance.X, mapEntrance.Y);
        //Node end = entrances[0];
        //if(tradeDirection == TradeDirection.Import)
        //	target.GetComponent<StorageBuilding>().Queue[co.item] += co.amount;

        //string caravanName = tradeDirection == TradeDirection.Import ? "Importer" : "Exporter";
        //Stack<Node> path = worldController.Map.pathfinder.FindPath(start, end, WalkerDatabase.GetData(caravanName));
        //if (path.Count == 0)
        //	return;

        //GameObject go = worldController.SpawnObject("Walkers", caravanName, start);

        //Walker w = go.GetComponent<Walker>();
        //w.Order = co;
        //w.world = worldController;
        //w.Origin = mapEntrance;
        //w.Destination = target;
        //w.Path = path;
        //w.Activate();
    }