コード例 #1
0
 public override IPointAdapter GetNextLocation()
 {
     if (!GetRunningState(location.GetX(), location.GetZ())) //check if tumble
     {
         angle = CalculateTumbleAngle();
     }
     CalculateNextLocation(location); //calculate next position
     return(location);
 }
コード例 #2
0
    public void Notify(Cell cell)
    {
        IPointAdapter point = cell.GetNextLocation();
        Movement      tmp   = Instantiate(eColi, new Vector3(point.GetX(), 1, point.GetZ()), Quaternion.Euler(0, cell.GetAngle(), 0));

        tmp.SetCell(cell);
        // Play lil particle effect
        var cellBirthMain = cellBirth.main;

        cellBirthMain.simulationSpeed = model.GetTimeScaleFactor();
        Instantiate(cellBirth, new Vector3(point.GetX(), 2, point.GetZ()), Quaternion.Euler(0, cell.GetAngle(), 0));
    }
コード例 #3
0
    protected void CalculateNextLocation(IPointAdapter location)
    {
        float dX = v * dT * MathFloat.Cos(angle), dZ = v * dT * MathFloat.Sin(angle);

        while (location.GetX() + dX > 14 || location.GetX() + dX < -14 || location.GetZ() + dZ > 14 || location.GetZ() + dZ < -14)
        {
            angle = CalculateTumbleAngle();
            dX    = v * dT * MathFloat.Cos(angle);
            dZ    = v * dT * MathFloat.Sin(angle);
        }
        location.Add(dX, dZ);
    }
コード例 #4
0
    // Start is called before the first frame update
    void Start()
    {
        model = Model.GetInstance();
        model.AddListener(this);
        List <Cell> cells = model.GetCells(0);

        if (cells == null)
        {
            return;
        }

        for (int i = 0; i < model.GetNumCells(0); i++) //create the E-Coli objects for the cells
        {
            IPointAdapter point = cells[i].GetNextLocation();
            Movement      tmp   = Instantiate(eColi, new Vector3(point.GetX(), 1, point.GetZ()), Quaternion.Euler(0, cells[i].GetAngle(), 0));
            tmp.SetCell(cells[i]);
        }

        AbstractEnvironment environment = model.environment;

        if (environment is MultiLigandEnvironment)
        {
            foreach (Environment env in ((MultiLigandEnvironment)environment).GetEnvironments())
            {
                Instantiate(food, new Vector3(env.GetX(), 1.88f, env.GetZ()), Quaternion.identity);
            }
        }
        else
        {
            Instantiate(food, new Vector3(environment.GetX(), 1.88f, environment.GetX()), Quaternion.identity);
        }
    }
コード例 #5
0
    //Method that returns the number of cells that are within a given distance of the given location
    //only to be used with cells that have a ForwardsInternals as their internals (since iteration does not make sense otherwise)
    public int GetNumOfCloseCells(int iteration, float distance, IPointAdapter location)
    {
        int num = 0;

        distance *= distance; //removes the need for sqrt operation

        foreach (Cell cell in cells[iteration])
        {
            if (!(cell.GetInternals() is ForwardInternals))
            {
                continue;
            }
            IPointAdapter cellLocation = ((ForwardInternals)cell.GetInternals()).GetPosition(iteration);
            if (MathFloat.Pow(cellLocation.GetX() - location.GetX(), 2) + MathFloat.Pow(cellLocation.GetZ() - location.GetZ(), 2) <= distance)
            {
                num++;
            }
        }

        return(num);
    }
コード例 #6
0
 public IPointAdapter GetNextLocation()
 {
     location = CalculateNextPoint(location.GetX(), location.GetZ(), model.environment);
     return(location);
 }
コード例 #7
0
 public bool Equals(IPointAdapter other)
 {
     return(point.x == other.GetX() && point.z == other.GetZ());
 }
コード例 #8
0
 private Vector3 TranslateToVector3(IPointAdapter pointToTranslate) => new Vector3(pointToTranslate.GetX(), transform.position.y, pointToTranslate.GetZ());